If all you need is an extra column have a look at col3 in SQLFORM http://web2py.com/book/default/chapter/07#SQLFORM
On Nov 10, 5:33 am, villas <villa...@gmail.com> wrote: > The function looks interesting, but I didnt understand how to create > the cols var. > > def mytable(rows, cols): > return TABLE(*[TR(*[TD(row[c]) for c in cols]) for row in rows]) > > I would be grateful for an example how it might work. > > I did have this other idea to include an extra column, but I imagine > that it's not so elegant as above. > > rows = db(db.test.id>0).select() > extras = list() > for row in rows: extras.append('whatever') > > for row,extra in zip(rows,extras): > print TR(TD(row.id),TD(extra)) > > -D > > On Nov 9, 6:33 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > I see two options: > > > 1) use > > > db.table.field.represent = lambda value: DIV(value) > > > and give any representation you want to the field value. > > > 2) If this does not work make your own SQLTABLE helper: > > > def mytable(rows, cols): > > return TABLE(*[TR(*[TD(row[c]) for c in cols]) for row in rows) > > > On Nov 9, 11:36 am, villas <villa...@gmail.com> wrote: > > > > I want to customize the result of SQLTABLE so that it can make me a > > > nice table without lines and lines of code in my view file. To > > > achieve that, I need for example to: > > > > 1) Add columns to hold icons and links and extra stuff. > > > 2) Customize the rows, e.g. links which depend on content, different > > > icons etc > > > > After giving it some thought, I think I should leave SQLTABLE alone > > > and concentrate on 'improving' the rows object so that it contains > > > everything I want before passing it to SQLTABLE. > > > > To do 1) I can simply add a column to the rows object. How can I best > > > do that? > > > To do 2) I could iterate the rows object and make changes. > > > > Or.... maybe there is another way. > > > I appreciate that if I want to style the HTML table, I'll have to > > > write my code in the form (which I am trying to avoid). > > > > Thanks, > > > -D