> You'll need to wrap the widget in someting that gets the attribute you
> want. Try something along the lines of:
>
> from operator import attrgetter
>
> def attrwidget(attr, widget):
>     _get_attr = attrgetter(attr)
>     def getter(obj):
>         return widget.display(_get_attr(obj))
>     return getter
>
> sortable_person_list = PaginateDataGrid(
>     fields=[
>         PaginateDataGrid.Column('name',
>                                 attrwidget('name', TextField('name')),
>                                 'Name',
>                                 options=dict(sortable=True)),
>         PaginateDataGrid.Column('age',
>                                 attrwidget('age', TextField('age')),
>                                 'Age',
>                                 options=dict(
>                                     sortable=True,
>                                     reverse_order=True)),
>     ])

Works perfectly. Thanks a lot!

I guess this is an ideal pattern of showing widgets in a datagrid, and
also providing edit facility by enclosing the grid in a form. Is not
so?

Sanjay


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to