Good point. I guess it depends on how many features are needed. My own 
experience is that using the DOM parser to modify grid parts like the 
buttons gets it pretty far along -- obviously, a lot would be missing, but 
there is so much useful stuff even with a very basic version of the grid 
(i.e., search bar not included).

On Tuesday, September 22, 2015 at 3:22:00 PM UTC-4, Anthony wrote:
>
> 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 (which will ultimately get rendered as a 
> SQLTABLE, which is not quite the same as the grid HTML table). This 
> approach will also break pagination, searching, sorting, and downloading. 
> So, without the standard grid HTML table or any of the other grid features, 
> you really get very little out of using the grid in this way.
>
> Instead, you could do steps 1-3 above, and then replace step 4 with:
>
> grid = SQLTABLE(t_rows)
>
> However, it would probably be easier to just write some code to directly 
> build an HTML table from the original JSON data rather than bothering with 
> steps 1-3. This would also allow for more flexibility in specifying the 
> HTML structure of the table.
>
> Even better, just use an existing data grid solution, such as Datatables 
> <http://datatables.net/>, which can consume JSON data directly.
>
> 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