i see how in this code, you can preset postdata filters by have this in your javascript.
postData: {
filters:'{"groupOp":"AND","rules":['+
'{"field":"invdate","op":"gt","data":"2007-09-06"},'+
'{"field":"invdate","op":"lt","data":"2007-10-04"},'+
'{"field":"name","op":"bw","data":"test"}]}'
}
is there any API that allows you to build this up. Something like:
jqgrid("#grid").addPostDataFilters("AND");
jqgrid("#grid").addFilteritem("field", "cn", "value");
jqgrid("#grid").addFilteritem("field1", "eq", "value2");
to help generate to top postdata filter code ??
i tried this but it doesn’t seem to work:
.jqGrid("setGridParam", { editurl: "/Project/UpdateMe",
ondblClickRow: function (rowid) {
editProject(rowid); // window.location.href="/Project/Detail/"+rowid;
}
});
var grid = $("#grid");
var f = { groupOp: "AND", rules: [] };
f.rules.push({ field: "Name", op: "cn", data: "volat" });
grid.p.search = f.rules.length > 0;
$.extend(grid.p.postData, { filters: JSON.stringify(f) });
Update:
I have this working now (thanks to Oleg) but ifor some reason the Find button somethng comes up with blank (even thought i do have an advanced filter set) i have added a picture

The filter
which you included in the question is serialized to JSON version of the object
which can be easy constructed dynamically:
if the grid already exist you want to reload the grid with the settings you can use
instead. The function
JSON.stringifyis supported by the most web browsers natively, but to be sureyou should include json2.js on your page.