Answer the question
In order to leave comments, you need to log in
How to sort the selection by status?
There are post statuses: 1. New, 2. Expired, 3. In Progress, 4. Resolved, 5. Archived.
Each entry has only one of the listed statuses.
It is necessary to withdraw the expired ones first, then the new ones, and then all the rest.
As I understand it, you need to
SELECT * FROM TABLE ORDER BY status_id=2 DESC, status_id=1 DESC, status_id ASC;
$dataProvider->query->orderBy(['status_id' => [2, 1]]);
Answer the question
In order to leave comments, you need to log in
Sorting is configured via the sort property date of the provider
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> [
'attributes' => [
'age',
'name' => [
'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC],
'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC],
'default' => SORT_DESC,
'label' => 'Name',
],
],
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question