diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index 8c8216b73..a9737455e 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -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