Skip to content Skip to sidebar Skip to footer

Calculated Fields In Web2py Sqlgrid

Web2py has several methods for calculated fields, but the documentation states that lazy fields 'are not visualized by default in tables' because they don't come with attributes li

Solution 1:

Unfortunately, I don't think there is an easy way to display virtual fields in SQLFORM.grid. What you can do is use the "links" argument and add each virtual field as a link (if "links" is a dictionary, each item will become a separate column in the grid).

links=[dict(header='myfield', body=lambda row: row.myfield)]

Note, in this case, you cannot specify the "fields" argument (i.e., you cannot specify only a subset of the fields for inclusion in the grid) -- this is because the virtual field function needs all the fields in order to work. If you need to hide some of the fields, you can instead set their "readable" attibute to False.

Another option might be computed fields.

Post a Comment for "Calculated Fields In Web2py Sqlgrid"