Reputation: 2175
i have a SQL query
family_members = db(\
db.member.parent_membership_id==parent_id.membership_id\
).select(\
db.member.first_name, db.member.parent_membership_id)
I want to display "family_members" as a table in my form.
How can i do this?
Upvotes: 2
Views: 1775
Reputation: 11579
You can follow the example I've shown you in a previous question.
Make sure to also check the documentation on the web2py website, seeing the work you are doing with this framework I would recommend to buy the web2py official manual which is really not expensive and will save you a lot of precious time. You can also read it online from the link I gave you, or download a few free chapters.
Basically you have two options,
SQLTABLE
TABLE
and so on, from the gluon
library).To illustrate that a little bit:
family_members = db(...).select(...) # your rows construct
table = SQLTABLE(family_members, orderby=True, _class='sortable', _width="100%")
If you want to add a column, for example:
table[0][0].append(TH("details"))
for i, value in enumerate(table[1]):
table[1][i].append(TD("line %d" % i, _align="center"))
Upvotes: 2