Since my web application needs to render more than two tables I was too lazy to write/copy/paste table html code over and over again. Instead I implemented render_table which does the job nicely. Everything starts out with one or more database query result sets. Columns are reordered and reassigned to a new target table that shall be rendered.
Is there a better built-in web2py-ish way to achieve the same? Regards, Andreas balo...@gmail.com -- views/render_table.html -- {{def render_table(table): # render table with header and attributes # string table.colnames[] # string table.colattrs[] # string table.rows[][] }} <table> <thead> {{for cn in table.colnames:}} <th>{{=cn}}</th> {{pass}} </thead> {{for n, row in enumerate(table.rows):}} <tr{{if n % 2 == 0:}} class='even'{{else:}} class='odd'{{pass}}> {{for cn, col in zip(table.colnames, row):}} <td{{if cn in table.colattrs:}} {{=table.colattrs[cn]}} {{elif isinstance(col, float) or isinstance(col, int):}} align='right' {{pass}}>{{=col}}</td> {{pass}} </tr> {{pass}} </table>{{pass}} -------------