I think maybe Thadeus meant SQLFORM.... or SQLFORM.factory.... You can give several tables to SQLFORM.factory. You can display a form (or fields) without making them editable by making the fields not writeable (you don't need to do this in the table - you can do it in the controller, only just before you create the form).
SQLFORM also has a readonly parameter for displaying only --- see http://www.web2py.com/book/default/section/7/2?search=readonly Hope that helps.... On Jun 19, 11:58 am, baloan <balo...@googlemail.com> wrote: > How will SQLTABLE help here? > > # non-executable pseudo code > result_a = db().select(db.sometable.ALL) > result_b = db().select(db.othertable.ALL) something like: .... in your controller: form = SQLFORM.factory( db.sometable, db.othertable, readonly=True ) return dict(form=form) .... in your view: {{ = form }} > rows_c = [] > for row_a, row_b in zip(result_a.response, result_b.response): > row_c = (row_b[3], '%.2f' % (row_a[0], ), int(row_b[1]), ...) > rows_c.append(row_c) > colnames = ('Datetime', 'float', 'n/sec', ...) > # How will I create an SQLTABLE here? > > -- > Andreas > > > > > Isn't this what SQLTABLE and crud.select is for? > > > -- > > Thadeus > > > On Sat, Jun 19, 2010 at 8:06 AM, baloan <balo...@googlemail.com> wrote: > > > 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}} > > > -------------