I'm using sortModel like this...
var sortModel = {
type: 'local',
single: false,
space: true
}
My column is this...
{ title: "Value £", minWidth: 70, align: "center", dataIndx: "diffval", dataType: "float", editable: false,
filter: { type: 'textbox', condition: "between", listeners: ['keyup'] }
}
...where diffval is a calculated column that I build running a function from "load" like I found in one of your other forum answers like this...
function computeDifferences(rowData) {
var diffQty;
if (rowData.total != null && rowData.mrpqty != null) {
diffQty = Number(rowData.total) - Number(rowData.mrpqty);
}
var diffVal;
if (diffQty != null) {
rowData.diffqty = diffQty;
if (rowData.unitcost != null && rowData.unitcost != "") {
diffVal = Number(diffQty * Number(rowData.unitcost));
rowData.diffval = diffVal;
} else {
rowData.diffval = "";
}
}
}
myGrid.on("load", function () {
var grid = this,
data = grid.option('dataModel.data');
for (var i=0, len = data.length; i<len; i++) {
var rowData = data;
computeDifferences(rowData);
}
});
If somebody forgot to fill in 'unitcost' in my database then the calculated value difference is not valid. In this case I would prefer to leave the calculated value difference as null. Null is better than Zero here because a calculated value difference of zero would mean we have an exact price match rather than an unknown price. If I remove this line...
} else {
rowData.diffval = "";
...so that the diffval remains null or undefined then the sort doesn't work clicking the column header (i.e. sorting value differences from highest to lowest). But if I set the cell to "" as original code above then the sort works correctly.
Furthermore I want to format the column as currency, but I can't seem to test for "" and 0 (zero) as different so both end up as £0.00, then you can't distinguish them on the grid. I can test for Null and 0 (zero) so they can be distinguished on the grid, but as explained above the sort no longer works if Null is in the cells.
If I have not confused you further with my explanations, then I would welcome your suggestions.
Best regards.