On Tuesday 29 January 2008 20:16:55 Foo Bar wrote:
> Hello!
>
> I recently inherited a small TG project and need to make a couple of
> changes to it now. While I am trying to learn about TG as I go, I have
> now come across a particular problem for which I might need some
> assistance.
>
> Actually, there are two questions:
>
> 1. I use the DataGrid widget to display a table in a form. It appears
> to me as if the various columns can only be filled with values read
> from the SQAlchemy objects. I need to add some more or less static, or
> even computed values to as columns as well, though. How can I specify
> that? I guess I could provide specific object methods for that, so
> that the widget can use them. However, logically, those values are not
> really part of the object.
You can pass a callable which will return the column-value. It gets passed the
current row object, but that you can ignore. Something like this (untested):
def compute_foo(row):
return kid.XML("""<a href="#">foo</a>""")
bookables_grid = vw.SortableDataGrid(name='bookables_grid', fields=[
('foo', compute_foo)
])
> 2. The grid in question lists a couple of items. At the bottom I
> would like to have an empty field and an 'Add' item, which allows
> users to add another item to the list. I have that working so far.
> Once added, the page is being redisplayed and shows one more item as
> intended. But next to each item I would now like to display a list of
> possible 'actions' (see point 1), one of them being 'delete' for
> example. It appears to me that TG's form handling would expect the
> button at the bottom to be pressed, though. Is there a way to have
> multiple exits out of the form? One being the button, the other being
> one of the action links next to each item?
Yes, alter the above code to have the link contain all necessary parameters.
Diez
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---