jqGrid does not support Date
as a native data type in comparison operations, so I offer you two paths as a workaround.
1) You can use the sorttype
function as a function. In the case when the function will be called with the Date
parameter, and the function can return a string that can be used instead of the date in comparison operations. for instance
sorttype: function (d) { if ($.isFunction(d.toISOString)) { return d.toISOString(); } return ISODateString(d);
2) You can extend the _ compare function used inside jqGrid to support the Date
type. You can use the trick I described in my old answer . If using _compare
code will be
var oldFrom = $.jgrid.from; $.jgrid.from = function (source, initalQuery) { var result = oldFrom.call(this, source, initalQuery), old_compare = result._compare; result._compare = function (a, b, d) { if (typeof a === "object" && typeof b === "object" && a instanceof Date && b instanceof Date) { if (a < b) { return -d; } if (a > b) { return d; } return 0; } return _compare.call(this, a, b, d); }; return result; };
You can paste the code before using jqGrid, as shown in the demo .
UPDATED : I sent a transfer request that fixed the problem.
source share