我有一个带有一些记录的 jqGrid,并希望根据多个条件过滤记录。
例如,如果有三列,名称、年龄和城市,我想在以下条件下过滤网格:
Name = "Mark" and Age = 25 and City = 'NY'
以下代码工作正常 -
var grid = jQuery("#memberDetails");
var postdata = grid.jqGrid('getGridParam', 'postData');
var filterArray = new Array();
var filterConidtion;
filterConidtion = new Object();
filterConidtion.field = "name";
filterConidtion.op = "eq";
filterConidtion.data = "Mark";
filterArray.push(filterConidtion);
filterConidtion = new Object();
filterConidtion.field = "Age";
filterConidtion.op = "eq";
filterConidtion.data = "25";
filterArray.push(filterConidtion);
filterConidtion = new Object();
filterConidtion.field = "City";
filterConidtion.op = "eq";
filterConidtion.data = "NY";
filterArray.push(filterConidtion);
jQuery.extend(postdata, {
filters: {
"groupOp": "and",
"rules": filterArray
}
});
grid.jqGrid('setGridParam', {
search: true,
postData: postdata
});
grid.trigger("reloadGrid", [{
page: 1
}]);
但我不确定如何使以下过滤器工作:
Name = "Mark" and Age = 25 and (City = 'NY' OR City = 'FL')
在groupOp
AND 或 OR 条件下工作,不确定如何在groupOp
谢谢。