Thanks for pointing of the problem of definition custom unary operations. I committed the changes of the code of free jqGrid to allow to specify the custom unary operations inside of new option customUnaryOperations
.
The demo defines two custom filtering operations: "em" ("is empty") and "nm" ("isn't empty") and use the operations in "Amount" and "Notes" columns. The column "Notes" uses additionally the standard (predefined) "nu" ("is null") and "nn" ("is not null") operations. The column "amount" uses
searchoptions: {sopt: ["eq", "ne", "em", "nm"]}
and the column "note" uses
searchoptions: {sopt: ["cn", "bw", "ew", "eq", "bn", "nc", "en", "nu", "nn", "em", "nm"]}
additionally the demo uses customSortOperations
and new customUnaryOperations
:
customUnaryOperations: ["em", "nm"],
customSortOperations: {
em: {
operand: "=''",
text: "is empty",
filter: function (options) {
var v = options.item[options.cmName];
if (v === undefined || v === "") {
return true;
}
}
},
nm: {
operand: "!=''",
text: "isn't empty",
filter: function (options) {
var v = options.item[options.cmName];
if (v !== undefined && v !== "") {
return true;
}
}
}
}