M
M
Max2016-06-02 16:53:24
Yii
Max, 2016-06-02 16:53:24

How to make correct sorting in CGridView?

Hello.
I have a table with columns due_date , status

`due_date` date DEFAULT NULL,
`status` enum('processing','new','progress','pending','completed','deleted') DEFAULT 'processing',

On the page, using GridView, you need to display data from the table in the following order:
1. First, there should be rows whose status can be processing || new || progress || pending + due_date ASC
2. And then with the status completed || deleted
Only UNION comes to mind, but I don't know yet how it will behave with paginator, filter, etc.
Any ideas? Maybe someone faced similar?
Example:
=== Given ===
Task 1 | 06/05/16 | completed
Task 2 | 06/07/16 | progress
Task 3 | 06/08/16 | deleted
Task 4 | 06/09/16 | new
Task 5 | 06/10/16 | new
=== Need to get ===
Task 2 | 06/07/16 | progress
Task 4 | 06/09/16 | new
Problem 5 | 06/10/16 | new
Problem 1 | 06/05/16 | completed
Task 3 | 06/08/16 | deleted

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CodeKeeper, 2016-06-03
@matios

You most likely need multisorting.

SELECT * FROM yourtable
ORDER BY `DATE` DESC, `IMPORTANCE` DESC

Taken from here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question