On 23 Feb., 08:09, Christoph Zwerschke <[email protected]> wrote:
> ruko schrieb:
>
>
>
> > "Diez B. Roggisch" <[email protected]> wrote:
>
> >> 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 alink<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?
>
> Use the function mentioned by Diez as field accessor (second element in
> the tuples defining the Columns).
>
> Seems we need some documentation here; I just opened a ticket for that
> (http://trac.turbogears.org/ticket/2235).
>
thanks Christoph for opening a ticket.


I tried this:

(1)
--------------------------------------------
def makeEditLink(id):
    return Markup("""<a href="/edit/%s" >Edit</a>""" % id)

name_grid = [("Edit", makeEditLink), ("Name", "name"), ("Birth",
"birth")]

I got this link:
http://10.172.1.113:8090/edit/<namecollection.model.name.Names object
at 0x27ff490>
--------------------------------------------

(2)
--------------------------------------------
def makeEditLink(id):
    return Markup("""<a href="/edit/%s" >Edit</a>""" % id.link)

name_grid = [("Edit", makeEditLink), ("Name", "name"), ("Birth",
"birth")]

I got this error (obviously):
AttributeError: 'Names' object has no attribute 'link'
--------------------------------------------

(3)
--------------------------------------------
def makeEditLink(id):
    return Markup("""<a href="/edit/%s" >Edit</a>""" % id)

name_grid = [("Edit", makeEditLink), ("Name", "name"), ("Birth",
"birth")]

I got this error:
AttributeError: 'Names' object has no attribute '<a href="/edit/<built-
in function id>" >Edit</a>'
--------------------------------------------

(Nearly everybody, who tries to present the data in a grid/table, has
this problem! How shall we select an item for editing or select an
item for buying? I think, it is one of the basics of developing
professional webpages.)

Any ideas?

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