Hi,
if you define the getter of the grid column as a string, it will be used to
return the value of an object attribute (getattr(obj, name)). If you want
to define a custom accessor, the getter must be a callable that defines the
column behavior. In specific:
contactinfo_grid = DataGrid(fields=[
('name', lambda row: row.get('name')),
('surname', lambda row: row.get('surname')),
('phone', lambda row: row.get('phone'))
])
Il giorno sabato 12 maggio 2012 08:44:34 UTC+2, Db ha scritto:
>
>
> Is it possible to load a Datagrid without sqlalchemy help ?
>
> Current testing code snippets:
>
> from tw.forms import DataGrid
>
> contactinfo_grid = DataGrid(fields=[
> ('name','name'),
> ('surname','surname'),
> ('phone','phone')
> ])
>
>
> and this code inside the controller:
>
>
> @expose('p1.templates.index')
> def index(self):
> data=[{'phone': '123456', 'surname': 'Sample', 'name': 'Frank'}]
> return dict(page='index', grid=contactinfo_grid, data=data)
>
>
> in the index.html:
>
> <div>${grid(data)}</div>
>
>
> Obviously the data is not in the correct format, but what should it look
> like?
>
> The idea is to just reuse existing, well tested sql queries from a pyqt
> application ,
> which we intend to port to tg2 , without going thru sqlalchemy magic.
>
>
> Thanks for any pointers
>
>
> Db
>
>
>
>
>
>
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/turbogears/-/6cTku4f2Ce8J.
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.