Hi,
Is there a way to retrieve the table field names dynamically when configuring the Data Grid widget ?
I could specify the column titles dynamically through template variales, but such approach does not work for the names of the table columns (fields).
Here are 2 screenshots:
1) The config : www.altipoint.ch/dev/screenshot_data_grid_config.jpg
2) The output : www.altipoint.ch/dev/screenshot_data_grid_output.jpg
One sees that specifying the name of the first table field in [*champ1*] does not work as nothing is outputed in the first column.
This forces me to create a new Data Grid widget for each MySQL table that I want to display.
Is there some trick ?
Thanks.
Hi your links aren’t working so I can’t see your problem.
However, I’ve been wrestling with the Datagrid because I had a client that wanted to be able to upload customer data onto his website for them to view.
I pulled together a solution using the datagrid widget but hit a snag when I discovered that there’s no way to set the grid to display all the fields in the table without first listing them in the Field Names.
That wasn’t workable in this instance because uploads for different customers were likely to need different columns.
The solution was a small mod to the datapager.class.php file in manager/includes/controls changing line 146
from:
$ row = $ this-> _isDataset? mysql_fetch_assoc ($ this-> ds): $ this-> ds [$ r];
TO:
$ row = $ this-> _isDataset? mysql_fetch_array ($ this-> ds): $ this-> ds [$ r];
This causes the widget to display all the available fields. If your data is small and you don’t specify page length in the widget you will need to make this change in the datagrid.class.php file instead.
Mike
Hi Mike,
That’s interesting. Thanks.
I had many tables with common fields ("key and value"), so I just created a new widget for them, but I’ll remember your trick for future uses of the Datagrid widget.
Cheers,
Julien
P.S.: I removed the screenshots a few days ago. I’m sorry.