When you have a column that displays composite data using an arbitrary field (ex., you're displaying a
fullname, and your actual db fields are
firstname,
middlename, and
lastname), you need to set the sort property on an existing db field. An effective way of doing this is:
In your grid js file, within the grid config:
fields: ['id','fullname','firstname','middlename','lastname',...],
paging: true,
remoteSort: true,
columns: [{
dataIndex: 'fullname',
sortable: true,
...other opts...
},{
...more columns...
Then in your GetList processor, knowing that extJS sends the $_REQUEST variables sort and dir when you click a column to sort:
public function prepareQueryBeforeCount(xPDOQuery $c) {
if($_REQUEST['sort']=='fullname'){
$this->setProperty('sort','lastname');
/*
Note, the following does not work, in both this and the
prepareQueryAfterCount method because of the sequence of method calls:
$c->sortby('lastname',$_REQUEST['dir']);
*/
}
...criteria customizations, if applicable...
return $c;
}
[ed. note: smg6511v2 last edited this post 13 years, 8 months ago.]