I have to put a record always in the top of the table (at the first line).
I can identify this record by the field "priority".
Only one record have a priority egal to 1, the others are 0.
First, I sorted the data grid by the priority :
Code: Select all
$sql = "SELECT id, name, priority, myField FROM myTable";
$default_order_field = "priority, name";
$default_order_type = "DESC, ASC";
By default, it works.
Now, my problem is if the user want to sort by another field. For example, by "myField". The "ORDER BY priority" is broken and the high priority valued doesn't appear in the first line.
I think there is two ways to resolve this :
- 1) If it's possible, the grid must launch two sql request :
- first "SELECT id, name, priority, myField FROM myTable WHERE priority = 1";
- then "SELECT id, name, priority, myField FROM myTable WHERE priority = 0";
Then make a pile with both results... I don't think that it would be easy, tbh.
- 2) Maybe the best solution : hardcode the fact that the grid must sort by "priority" at first, then by the header selected by user.
How/where can I do this ? Did you have a better idea ?