On 31 Jan., 18:50, "Diez B. Roggisch" <[email protected]> wrote:
> Michael Pearce schrieb:
>
>
>
>
>
> > On Sat, Jan 31, 2009 at 7:12 AM, Jim Steil <[email protected]
> > <mailto:[email protected]>> wrote:
>
> >     Michael Pearce wrote:
> >      > Not sure if anyone saw my previous email. I haven't seen a response
> >      > yet so I'll try one more attempt (as getting desparate now). My
> >      > application is displaying aDataGridwidgetvia a Genshi template. I
> >      > would like the data in one column to be displayed as a hreflinkso
> >      > that users can click on any of the records in order to display an
> >     edit
> >      > screen for that particular record. Now, one of the Turbogears
> >      > tutorials shows an example of this using Kid templates. This method
> >      > uses the Kid Element object which is passed to theDataGridon
> >      > creation. I have no problem getting the tutorial example to work,
> >      > however I'm not sure what needs to be passed to theDataGridwhen
> >      > using Genshi. I have searched the Geshi documentation but cannot find
> >      > a relevant example to help solve my problem. Any assistance would be
> >      > greatly appreciated.
>
> >      > Thanks,
> >      > Michael
>
> >     Can you post a sample of your code?
>
> > Here is a sample based on an example on the genshi website:
>
> > from genshi.builder import Element, tag
>
> > def get_link(gridVal)
> >    link= tag.a(gridVal, href="target")
> >     returnlink
>
> > the function then gets called when I create thedatagrid.
>
> > Another example from genshi that I tried is:
>
> > def get_link(gridVal):
> >    link= Element('a')(gridVal, href="target")
> >     returnlink
>
> > Both of these return the error:
>
> > AttributeError: 'Element' object has no attribute 'text'
>
> > This is strange as I'm not even using a 'text' attribute.
>
> I never saw the above way to create things, however I think this should
> work:
>
> from genshi import Markup
>
> def get_link(item):
>      return Markup("""<a href="%s" >Link</a>""" % item.link)
>
> Diez

sorry, but I didn't get it.

An example:
-------------------------------
name_grid = [("Edit", "id"), ("Name", "name"), ("Birth", "birth")]

class RootController(BaseController):
    # some others ...
    @expose("genshi:namecollection.templates.names_list")
    def list(self, **kw):
        """a simple list for Names"""
        names = DBSession.query(Names)
        pylons.c.name_grid=DataGrid(fields = name_grid)
        pylons.c.name_data=DBSession.query(Names).all()
        return dict(names=names, page='Name List')
-----------------------------

I would like to have a link <a href="/edit/value_of_id">Edit</a> in
the resulting grid in stead of the (value of the) id.

What's the code for that?

Rupert

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to