Yes it is possible, but Datagrid expects values to be objects with attributes instead of a dict. To workaround this issue you can store the values (or convert the dict to) a tg.util.Bunch object which will provide access both with __getitem__ and __getattr__.
In any case DataGrid permits to pass any callable to retrieve the column values when declaring the fields attribute instead of property name. Give a look at the DataGrid tutorial for more informations: http://www.turbogears.org/2.1/docs/main/DataGrid/index.html On Sat, May 12, 2012 at 8:44 AM, Db <[email protected]> wrote: > > 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/-/A57pZW-XqFkJ. > 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. -- 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.

