tags:

views:

79

answers:

2

i have a SQLrows

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?

Thanks in advance

+1  A: 

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,

  • use the SQLTABLE
  • if you want further control on the table, you can transform the result given by the above option (it's a class you can use to modify the contents), or create it entirely on your own with the HTML helpers (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"))
RedGlyph
+1  A: 

In view:

{{=family_members}}
mdipierro