0

My goal is to do a dynamic filter on my jqGrid. The expression looks like : (A OR B) AND ( C OR D OR E ) AND ... So, I created a global filter, with the "AND" clause and sub-groups with "OR".

The code:

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);

Finally, when I have a clause like "A AND B", it works well, but when the sub groups have more than one rules it doesn't. I have the impression that there is an OR between all the conditions. How can explain it ?

Thanks in advance for your help,

  • Which version of jqGrid you use (or have to use) and from which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7)? The filter which you build seems be correct. If you would use free jqGrid 4.13.4 then you can use `"in"` operation with comma separated values. It will eliminate the `groupOp: "OR"`. In general if you report a bug then it's better to create JSFiddle demo and describe the test case which can be used to reproduce the problem. – Oleg Aug 24 '16 at 15:30
  • I use free jqGrid in version 4.1.1. – user3531140 Aug 24 '16 at 15:48
  • Sorry, but the version is dead since many many years. It's more as 5 years old. It was published short time after publishing IE9. jqGrid 4.1.1 is oriented on IE6-IE8 mostly. I strictly recommend you to update retro version of jqGrid, which you use. "Free jqGrid" is the name of product, which I develop, after renaming of "jqGrid" to "Guriddo jqGrid JS" at the end of 2014 (see [the post](http://www.trirand.com/blog/?p=1438)) and making it commercial (see [the prices](http://guriddo.net/?page_id=103334)). Thus the version 4.1.1 is "jqGrid" and not "free jqGrid". – Oleg Aug 24 '16 at 16:08
  • Indeed, I update my "jqGrid" version to 4.6.0 and the problem is solved. Thanks Oleg. – user3531140 Sep 02 '16 at 12:51

0 Answers0