0

我的目标是在我的 jqGrid 上做一个动态过滤器。表达式看起来像: (A OR B) AND (C OR D OR E) AND ... 所以,我创建了一个全局过滤器,带有“AND”子句和带有“OR”的子组。

编码:

var globalFilter = { groupOp: "AND", rules: [], groups: []};

var filter1 = { groupOp: "OR", rules: []};
<#list listFilter1 as filter1>
    filter1.rules.push({field:"filterName1",op:"eq",data:filter1.name});
</#list>

var filter2 = { groupOp: "OR", rules: []};
<#list listFilter2 as filter2>
    filter2.rules.push({field:"filterName2",op:"eq",data:filter2.name});
</#list>


var filter3 = { groupOp: "OR", rules: []};
<#list listFilter3 as filter3>
    filter3.rules.push({field:"filterName3",op:"eq",data:filter3.name});
</#list> 

globalFilter.groups.push(filter1);
globalFilter.groups.push(filter2);
globalFilter.groups.push(filter3);

最后,当我有一个像“A AND B”这样的子句时,它运行良好,但当子组有多个规则时,它就不行了。我的印象是所有条件之间都有一个或。怎么解释呢?

在此先感谢您的帮助,

4

0 回答 0