I am trying to implement a custom sorting of the column UUID of my grid. I would like that the sorting reflects the sorting of the database by displaying the data for example in descending order, as follows:
select * from mytable order by uuid desc;
| id | uuid |
|----------+----------------------------------+
| 10094875 | |
| 10093749 | |
| 10094905 | |
| 10094887 | |
| 11268062 | fffffffffffffffffffff |
| 11268010 | fffffffffffffffffffff |
| 11267357 | ffffffffffff |
| 11267356 | fffff-fffff-ffff-ffff-ffff |
| 11267998 | eeda671280c7397c11347cb758e36b38 |
| 10250739 | eeda671280c7397c11347cb758e36b38 |
So in descending order, it should appear first the white spaces/empty item and after the UUID without the dashes, then the UUID with dashes.
At the moment these are my results when sorting descending:
It is close to what I want, but as you can see the empty rows are displayed at the bottom instead of the top. This is my code:
Ext.define('Traccar.model.MyModel', {
extend: 'Ext.data.Model',
identifier: 'negative',
fields: [{
...
}, {
name: 'uuid',
type: 'string',
sortType: function (actualValue, replaceValue, arg1, arg2) {
if (arg1 != null & arg2 != null) {
if (actualValue === arg1 || actualValue === arg2) {
return replaceValue;
} else
return actualValue;
} else if (arg1 != null) {
if (actualValue === arg1)
return replaceValue;
else
return actualValue;
} else
return actualValue;
}
}, ..
}],
});
Does anyone know how can I fix it?
