getting data from query with SQLFORM.grid

208 views
Skip to first unread message

Christian Espinoza

unread,
Apr 9, 2013, 9:38:48 AM4/9/13
to web...@googlegroups.com
Hi guys, I'm answering how can I take advantage from SQLFORM.grid in order to get aditionally the data from the query 
something like: 

SQLFORM.grid():
.
.
   
return (htmlcode, rawrows)


 grid, rows = SQLFORM.grid(query,fields=campos,
     editable
=False,
     searchable
=False,
     deletable
=False,
     create
=False,
     details
=False,
     user_signature
=False,
     
orderby=db_events.events.event_datetime
 
)

There are something working like that?

Thanks in advance.
Christian.

Massimo Di Pierro

unread,
Apr 9, 2013, 10:14:50 AM4/9/13
to web...@googlegroups.com
I do not understand the question. :-(

Christian Espinoza

unread,
Apr 9, 2013, 11:12:57 AM4/9/13
to web...@googlegroups.com
Hi Massimo, I'm rendering a grid in a view and I'm need add a graph to it, maybe using flot js lib
the graph will need the same grid data, and I'm wondering how get the row data without running a query only for the graphs
and taking advantage from the raw data used by SQLFORM.grid()...

Christian.

Massimo Di Pierro

unread,
Apr 9, 2013, 11:46:38 AM4/9/13
to web...@googlegroups.com
hmmmm... looks like the rows are not stored. I can easily change and allow you to do:


grid = SQLFORM.grid(...)
grid.rows = ....

it would contain the records you see on the page only. Would this be ok? Pros/Cons?

Christian Espinoza

unread,
Apr 9, 2013, 12:14:26 PM4/9/13
to web...@googlegroups.com
I think it will be a nice feature, would save have to querying the database twice when was required

Christian.


2013/4/9 Massimo Di Pierro <massimo....@gmail.com>

--
 
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Q6bEe_rscFw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Christian Espinoza

unread,
Apr 25, 2013, 5:43:50 PM4/25/13
to web...@googlegroups.com, Massimo Di Pierro
Hi Massimo, I'm wondering how apply this change, I tried with the last
version, but isn't work yet,
I thought that was implemented in gluon\sqlhtml.py line 2242...

I'm trying to call it on this way:

grid = SQLFORM.grid(....)

return dict(form=form, grid=grid, license_plate=license_plate,
summary=show_summary(summary), help=help, rows=grid.rows)

but I got this error:

Versión

web2py™Version 2.4.6-stable+timestamp.2013.04.21.19.50.11
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)

Traceback

Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/www-data/web2py/applications/avl/controllers/reports.py",
line 426, in <module>
File "/home/www-data/web2py/gluon/globals.py", line 194, in <lambda>
self._caller = lambda f: f()
File "/home/www-data/web2py/applications/avl/controllers/reports.py",
line 336, in events
return dict(form=form, grid=grid, license_plate=license_plate,
summary=show_summary(summary), help=help, rows=grid.rows)
AttributeError: 'DIV' object has no attribute 'rows'

Error snapshot

<type 'exceptions.AttributeError'>('DIV' object has no attribute 'rows')

Thanks for your time.
Christian.

2013/4/9 Massimo Di Pierro <massimo....@gmail.com>:
Reply all
Reply to author
Forward
0 new messages