Sorting model on related data

Discuss about Group-Office development here

Moderator: Developers

Posts: 5
Joined: Mon Sep 09, 2013 11:15 pm
Location: Belgium

Sorting model on related data

Postby huisvanheden » Fri Apr 25, 2014 12:00 am

Let's say I have a grid that displays a table from model 1 and this model has a relation with the table of model 2. When the model is rendered the id's from model 2 used in model 1 are changed to another column of model 2 (like in the presidents module using the formatColums method in the model 1 controller). Is it then possible to sort on the new information displayed of model 2? The default behaviour is that the default sort will be on the overridden data of model 1 and not the displayed data of model 2.
Huis van Heden
Group Office Reseller
Posts: 66
Joined: Fri Jun 21, 2013 2:55 pm

Re: Sorting model on related data

Postby richarddodd » Thu May 01, 2014 5:08 pm

I'm not 100% sure, but I think that the 4th parameter of the function `formatColumn` takes a string to label the field for sorting, so if you do something like

Code: Select all

$cm->formatColumn($columnName, $format, array(), 'sortName');
and then sort by 'sortName' it should sort on your new column.

Please correct me if I'm mistaken.

Who is online

Users browsing this forum: No registered users and 2 guests