RE: [PEAR] Sorting Structures DataGrid using Linked Values fetched via DataObject Linked Vlaues
| From: | John Trow-Smith | Date: | Tue, 14 Aug 2007 22:54:08 +0000 |
| Subject: | RE: [PEAR] Sorting Structures DataGrid using Linked Values fetched via DataObject Linked Vlaues | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-27817@lists.php.net to get a copy of this message | ||
hi Justin
Thank you for the quick reply. I thought it would be too good to be true :) I'll carry on
with my workaround.
Thank You
John
-----Original Message-----
From: Justin Patrin [mailto:papercrane@gmail.com]
Sent: Tue 8/14/2007 8:05 PM
To: John Trow-Smith
Cc: pear-general@lists.php.net
Subject: Re: [PEAR] Sorting Structures DataGrid using Linked Values fetched via DataObject Linked
Vlaues
On 8/14/07, John Trow-Smith <John@wcs.org.uk> wrote:
> 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?
>
Exactly right! The FB integration in the DO DG DS (heh) uses the FB
function that queries for the link's display value per record. The
ordering will go by the id value since that is done in the original
query. FB does a query per record to get these values instead of doing
direct linking as I never had the time to get linking support
integrated properly.
> Any help greatly appreciated.
>
--
Justin Patrin