I currently sort grid data in php using something like this
$grid->sort("Num1", "ASC");
$grid->sort("Num2", "ASC");
I would like to add a rule on a third value before these two sorting columns, the value would be a substring (actually an interger value of a substring) of a third field. This third value should be the first value the grid is sorted (before Num1 and Num2).
Now I have seen:
function custom_sort($sorted_by){
// SORT BY LENGTH(some_field)
$sorted_by->rules[0]["name"]="LENGTH(some_field)";
}
But what can I put on the right hand side of the “=” ? PHP code ? intval(substr()) ?
How do I defined this rule to be the integer value of a substring (or two substrings)? How can I say it has to be ascending or descending?
If I use a custom_sort, should I move my two sorting commands (on Num1, Num2) inside that function ?