Should be something like this: from tw.forms import DataGrid
class MyGrid(DataGrid): template = """ <table xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" id="${id}" class="${css_class}" cellpadding="0" cellspacing="1" border="0"> <thead py:if="columns"> <tr> <th py:for="i, col in enumerate(columns)" class="col_${i}"> ${col.title} </th> </tr> </thead> <tbody> <tr py:for="i, row in enumerate(value)" class="${i%2 and 'odd' or 'even'}"> <td py:for="col in columns"> <a href="/user/edit/${row.user_id}">${col.get_field(row, displays_on="genshi")}</a> </td> </tr> </tbody> </table> """ def update_params(self, d): super(MyGrid, self).update_params(d) mygrid = MyGrid(fields = [ ("User ID", "user_id"), ("User Name", "user_name"), ("Display Name", "display_name"), ("Email", "email_address") ]) Once again this creates link on all columns. In case you want to have it for only one column you will have to use py:when regards Sanjiv On Mon, Feb 23, 2009 at 8:26 PM, Lukasz Szybalski <szybal...@gmail.com> wrote: > > On Mon, Feb 23, 2009 at 12:10 AM, Sanjiv Singh <singhsanj...@gmail.com> wrote: >> >> Forget to mention one more thing. You have to add a py:choose/py:when/ >> py:otherwise block inside the for loop to have the link only for the >> intended column :) > > Is there an example how to subclass the datagrid? > > from tw.forms import DataGrid > class mydatagrid(DataGrid): > ......now what? > > Thanks, > Lucas > > > >> >> Sanjiv >> >> On Feb 23, 11:00 am, Sanjiv Singh <singhsanj...@gmail.com> wrote: >>> Hi Lucas, >>> >>> One way would be to subclass DataGrid and modify the template to have >>> something like this for the column >>> >>> <td py:for="col in columns"><a href="/some/path/${some_tmpl_var}">$ >>> {col.get_field(row, displays_on='genshi')}</a></td> >>> >>> regards >>> Sanjiv >>> >>> On Feb 22, 3:24 am, Lukasz Szybalski <szybal...@gmail.com> wrote: >>> >>> > On Wed, Jan 28, 2009 at 7:52 PM, Michael Pearce <mgpearc...@gmail.com> >>> > wrote: >>> > > Hi, >>> >>> > > I'm trying to display a DataGrid widget using Genshi templates, and I >>> > > want >>> > > one of the fields to be a <href> link. I have successfully tried the >>> > > tutorial using Kid templates, which creates a link using the Kid Element >>> > > object and passes it to the DataGrid, however I can't find an example >>> > > for >>> > > Genshi. I have looked through the documentation and unable to find an >>> > > equivalent Genshi object for creating a <href> link for my grid. Can >>> > > someone >>> > > please point me in the right direction. >>> >>> > Were you able to do it? >>> > Could you post a code that does it. >>> >>> > Thanks, >>> > Lucas >> > >> > > > > -- > How to create python package? > http://lucasmanual.com/mywiki/PythonPaste > Bazaar and Launchpad > http://lucasmanual.com/mywiki/Bazaar > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to turbogears+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---