Allow complex sortable columns

This commit is contained in:
flynsarmy 2014-08-23 17:35:18 +10:00
parent d2e2e1ffff
commit 9bf5821a3b
1 changed files with 11 additions and 1 deletions

View File

@ -402,6 +402,16 @@ class Lists extends WidgetBase
* Apply sorting
*/
if ($sortColumn = $this->getSortColumn()) {
// Determine if the column has an sqlSelect
foreach ($this->getListColumns() as $column) {
if ($column->columnName == $sortColumn) {
if ($column->sqlSelect) {
$sortColumn = $column->sqlSelect;
}
break;
}
}
$query->orderBy($sortColumn, $this->sortDirection);
}
@ -1042,7 +1052,7 @@ class Lists extends WidgetBase
//
// Helpers
//
/**
* Check if column refers to a relation of the model
* @param ListColumn $column List column object