I'm liking PHPGrid a whoile lot better than Koolgrid, but I've run into a stumbling block.
I have a table that needs a fixed sortorder — which involves a calculation. (specifically an enum field that I want extracted by the enum position rather than the text. You can accomplish by making it numeric in some fashion – like adding 0 or casting as integer)
But I can't get the 'sortname' parameter to accept anything other than pure field names. I think this is because you are escaping everything in quotes, and that then breaks functions, math, etc.
Even your example in forum question #1032930 fails me:
$grid["sortname"] = "FIELD(status, 'A', 'B', 'C', 'D', 'E')";
$grid["sortorder"] = "";
It throws an error. The resulting SQL in the dialog box shows all sorts of quoting:
group by s.family_id,s.student_id ORDER BY `FIELD(status, 'A', 'B', 'C', 'D', 'E')` DESC LIMIT 20 OFFSET 0
So if I wanted to sort by "status+0" or "cast(`status` as unsigned)" is there a way? Or is there a way to bypass the sortname / sortorder parameters altogether and let my query do the sorting?
We have disabled it due to security reasons as it was directly passed from GET url.
We're currently working on making it functional from backend and per field basis.
Will be emailing you the update.
With this update you can use custom sort expession with each column.
$col = array();
$col["title"] = "Gender";
$col["name"] = "gender";
$col["sortname"] = "FIELD(gender, 'Female', 'Male')"; // <=========================
$col["width"] = "30";
$col["editable"] = true;
$cols[] = $col;