>
> 1. Create a Table object with appropriate fields and set migrate=False 
> (This creates a dummy table) 
> 2. Convert row values into a list of tuples
> 3. Use db._adapter.parse to create a DAL Rows object using the dummy table:
>
> t_rows = db._adapter.parse(rows, fields=[f for f in db.dummy_table], 
> colnames=db.dummy_table.fields)
>
>
> 4. Create a SQLFORM.grid in controller and then replace the rows with your 
> rows object using the DOM parser.
>
> grid = SQLFORM.grid(db.dummy_table)
> table = grid.element('.web2py_table')
> table[0] = t_rows
>
>
I'm not sure this will be a fruitful approach. The code above won't quite 
work as is, as table[0] is supposed to be a TABLE html helper object, with 
a very specific structure and format, but the above code attempts to 
replace it with a DAL Rows object. This approach will also break 
pagination, searching, sorting, and downloading. So, without the HTML table 
or any of the other grid features, you really get nothing out of using the 
grid in this way.

If you have a set of records in JSON format, you're much better off using a 
solution such as Datatables <http://datatables.net/> (or even just manually 
building an HTML table via a loop in a web2py template).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to