Sorting Structures DataGrid using Linked Values fetched via DataObject Linked Vlaues
| From: | John Trow-Smith | Date: | Tue, 14 Aug 2007 15:29:14 +0000 |
| Subject: | Sorting Structures DataGrid using Linked Values fetched via DataObject Linked Vlaues | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-27813@lists.php.net to get a copy of this message | ||
Hi,
I'm using the DB_DataObject, DB_DataObject_FormBuilder and
Structures_DataGrid packages.
I can generate a datagrid and get the linked values displaying fine
using:
$datagrid->_addDefaultOptions(array(
'sort_property' => 'fb_linkOrderFields',
'link_property' => 'fb_linkDisplayFields',
'link_level' => 1);
This is a neat featuring making use of the links.ini and FormBuilder
variables and I really like it. But when I click to sort on one of the
fields populated with linked values, e.g. LocationIDlink, it sorts by
the underlying ID value rather than the text fetched for display from
TblLocations.
I can get things working by creating a new DataObject for the linked
table and then using $do->joinAdd() and $do->selectAdd() to get at the
fields and then using
$datagrid->addColumn(new Structures_DataGrid_Column('Location',
'LocationName', 'LocationName')); to generate the column I want. But
this seems a bit long-winded.
I'm guessing there is an option I'm overlooking somewhere... or is the
DataGrid DataSource DataObject just performing a function per record to
return the text to display in the manner of a custom formatter and thus
not ever going to be sortable?
Any help greatly appreciated.
Thank You
John