Well, in theory with Web2py we have models controllers and views.
However I find that 50% of the view work I have to do in
the .represent of the model. Then there is a lot of trial and error.
So the division of responsibilites is not as clean as one would hope.
Another reason for doing things in represent is make the image and the
title links, so that the user views the album by clicking on them.

As I said earlier, if you use the css for the grid things dont work,
so delete the css for the grid, it still looks good.

db.albums.image.represent=lambda image,row:
A(IMG(_src=URL('store','download_image',args=[row.id]),_height="150",_width="150"),_href=URL('store','show_album',args=row.id,
vars=request.vars))

db.albums.description.represent=lambda
d,r:SPAN(A(H2(r.album_name),_href=URL('store','show_album',args=r.id),_style="text-
decoration:none"),H3(r.artist),XML("<br>"+d[:
250]+".."+"<br><br><br>"))

As you see, I actually display the album name and and artist as part
of the description

The album name and artist columns contain blanks

                Field('album_name', represent=lambda a,d:' '),
                Field('artist',represent=lambda a,d:' '),

I do this so that I still have the columns present so that their
column headings can be used to sort on.

This is not ideal as the column headings are not in the right place,
however, I do not think there is a straightforward better solution.

Peter

On Oct 27, 1:28 pm, Johann Spies <johann.sp...@gmail.com> wrote:
> On 26 October 2011 21:20, peter <peterchutchin...@gmail.com> wrote:
>
>
>
> > Adding in the css for grid actually spoilt things. I have managed to
> > get a good looking grid for CDs with graphics using smartform.grid,
>
> How did you get wrapping of the text in the 'Description' column in your
> your grid (ifhttp://ukjazz.net/store/albumsis what you refer to)?
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)

Reply via email to