Quick DataGrid question for the list. I am attempting to embed a
DataGrid widget in my edit page in order to allow the user to modify
the properties of a related list of objects. From the code that I have
seen on using a DataGrid widget in a non-fastdata environment, there
appears to be a bit of "magic" involved in getting data to the widget.
According to the (excellent) DataGridWidget page in the wiki, it is
possible to provide DataGrid with a custom list of objects but I
haven't been able to find an example. I've also tried using a
DataController but since I would like to include other widgets on the
same page this does not seem to be an option.
Would someone be able to provide an example of how to specify the list
of objects to a DataGrid or point me in the right direction?
Any help would be greatly appreciated.
Iain
try http://trac.turbogears.org/turbogears/wiki/DataGridWidget
and as the widget API is going through some surgery, be sure to let
us know if you find anything broken ;)
Alberto.
Thank you for the response. Unfortunately, the DataGridWidget entry in
the wiki does not currently have the info that I was looking for. What
I was wondering is how to set the object list that a DataGrid widget
will use in a non-fastdata environment.
I've been able to get it working in a simpler case where I only have
one class in my model but things seem to break down when my model
contains more than one class.
Perhaps I'm just jumping in at the wrong time and should wait for 0.9
to be released?
Today Max began working on a refactoring of the DataGrid to make it
simpler to work in a non fastdata environment, actually, the fastdata
grid is now called FastDataGrid and the non-fastdata grid is called
DataGrid.
You can take at look at the code of the DataGrrid at:
http://trac.turbogears.org/turbogears/browser/trunk/turbogears/
widgets/datagrid.py
to see if it helps, maybe the wiki page has been updated too, but I'm
not sure
Unfortunately I can't help you any further (recipes, etc) as I
haven't got "my hands dirty" with it yet, sorry.
Hope it helps,
Alberto
But you can take a look at test file,
http://trac.turbogears.org/turbogears/browser/trunk/turbogears/widgets/tests/test_datagrid.py
The prinicple is simple, you create a DataGrid (using fields arg to
describe data layout) and then pass iterable at display time.
HTH,
Max.