我在navgrid工具栏上实现了一个按钮来执行自定义过滤搜索。搜索完成后,将显示正确的结果数,并且分页索引也会更改。当使用在分页内移动的任何按钮时,过滤器将丢失,并且网格将恢复为未过滤的结果。执行过滤搜索的功能是:
function jqGridFilter(filtersparam, grid, reload) {
grid.setGridParam({
postData: {
filters: filtersparam
},
search: true
});
if(reload == 1){
grid.trigger("reloadGrid");
}
};
var filters = { "groupOp": "OR", "rules": [{ "field": "y2012qval1", "op": "ne", "data": "0" },{ "field": "y2012qval2", "op": "ne", "data": "0" },{ "field": "y2012qval3", "op": "ne", "data": "0" },{ "field": "y2012qval4", "op": "ne", "data": "0" },{ "field": "y2013qval1", "op": "ne", "data": "0" },{ "field": "y2013qval2", "op": "ne", "data": "0" },{ "field": "y2013qval3", "op": "ne", "data": "0" },{ "field": "y2013qval4", "op": "ne", "data": "0" },{ "field": "y2014qval1", "op": "ne", "data": "0" },{ "field": "y2014qval2", "op": "ne", "data": "0" },{ "field": "y2014qval3", "op": "ne", "data": "0" },{ "field": "y2014qval4", "op": "ne", "data": "0" },{ "field": "y2015qval1", "op": "ne", "data": "0" },{ "field": "y2015qval2", "op": "ne", "data": "0" },{ "field": "y2015qval3", "op": "ne", "data": "0" },{ "field": "y2015qval4", "op": "ne", "data": "0" },{ "field": "y2016qval1", "op": "ne", "data": "0" },{ "field": "y2016qval2", "op": "ne", "data": "0" },{ "field": "y2016qval3", "op": "ne", "data": "0" },{ "field": "y2016qval4", "op": "ne", "data": "0" },{ "field": "y2017qval1", "op": "ne", "data": "0" },{ "field": "y2017qval2", "op": "ne", "data": "0" },{ "field": "y2017qval3", "op": "ne", "data": "0" },{ "field": "y2017qval4", "op": "ne", "data": "0" }] };
对此功能的调用是:
$grid.navButtonAdd(pagerName,
{
buttonicon:"ui-icon-star",
title:'Filter Rows Where Quarter Values Are All 0',
onClickButton : function () {
jqGridFilter(null , $(this),0);
jqGridFilter(filters , $(this),1);
jqGridFilter(null , $(this),0);
}
});
网格由远程JSON对象填充,并设置为loadonce:true。工具栏搜索也已启用,并且在使用工具栏搜索时分页不会还原。
有关如何将过滤分页与过滤保持在一起的任何想法,直到重新加载触发或刷新?
答案 0 :(得分:0)
对jqGridFilter函数的最后一次调用是清除过滤器参数,一旦我删除了最后一次调用,分页只使用过滤后的数据。