Re: Sorting Structures DataGrid using Linked Values fetched via DataObject Linked Vlaues
| From: | Justin Patrin | Date: | Tue, 14 Aug 2007 19:05:14 +0000 |
| Subject: | Re: Sorting Structures DataGrid using Linked Values fetched via DataObject Linked Vlaues | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27815@lists.php.net to get a copy of this message | ||
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