> Hi. I need to add field (column) to the SQLFORM.grid. The column is simple
> order number – just numbers 1,2,3,4,... at the beginning of every row.
>
I did not find a builtin feature of grid to make that, but can think of two
ways of doing this
a) Using virtual fields and the grid fields argument.
b) Using helper methods for customizing the table
I think b) is more simple to code but can have less performance than a)
b)
grid = SQLFORM.grid(query or table)
trs = grid.element("table").elements("tr")
grid.element("thead").insert(0, TH(<name>))
for i, tr in enumerate(grid.element("tbody").elements("tr")):
tr.insert(0, TD(i+1))
a) is just about setting a virtual field for the table with a record
counter and specifying it in the grid fields argument .
Also, as you can see, this field should NOT be viewed in update or create
> mode.
>
Perhaps you could read the request arguments so you can enable/disable the
row count when there was a record edit/update requested.
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.