Re: [datagrid] How to disble automatic sorting ?
| From: | Andrew Nagy | Date: | Mon, 28 Feb 2005 15:01:13 +0000 |
| Subject: | Re: [datagrid] How to disble automatic sorting ? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17728@lists.php.net to get a copy of this message | ||
Daniel García wrote:
Hi all, I'd like to use the header links in DataGrid to control sorting of records, but I'd like to handle sorting outside of DataGrid. Is that possible ? Sure, you will have to accept the GET values and use them to sort your data and then bind the new data to the datagrid.Since DG will want to process the GET values automatically, you can simply destroy the GET values befor instantiating the datagrid: unset($_GET); This should probably be an option, being able to disable automatic sorting/paging.
The reason is that the DB backend is sorting the resultset differently than the DataGrid: for example, the DB places numbers at the end, while DataGrid places them at the beginning. The result is that after paginating the result set (also handled externally to DataGrid in order to use DB::limitQuery instead of DB::getAll), the results look funny.Hmm ... the limitQuery would be a nice way to handle DB as a datasource. However at the current moment, the datagrid binds to the DB_Result object. Maybe it would be nice to bind to a SQL statment and datagrid could then use limitQuery to help with the limiting. You could always just change the sort method used in DataGrid, it is located in the array datasource file. Or create your own datasource driver. Hope this helps :) Andrew