I have a problem right now where I'm trying to filter by two columns by default, like so:
function filterGrid() {
$("#igGrid").igGridFiltering('filter', [ { fieldName: "Status", expr: "Closed", cond: "doesNotContain", logic: 'AND' }, { fieldName: "Name", expr: 'Joe', cond: "equals", logic: 'AND' } ]); };
The filters are applied correctly on load, but once you click 'x' to clear the "Name" filter, the "Status" filter goes from 'doesNotContain' to 'Equals', and messes up the filtered results. Is there any way arount this? this function is being called on the igGrid rendered callback.
(PS your 'insert code' option in the html editor does not work in the slightest. Text is edited about 15 characters left of the cursor, and when you click insert nothing happens. )
Hello Erik,
Thank you for getting back to us.
I created the following support case for you CAS-201604-K7J9R0. I have logged this behavior in our internal tracking system with an ID of 262977 and linked this issue with your newly created case. You could see it in your account on our web site in the Support Activity page once you log in with your credentials.
Please let me know if you need any further assistance.
That works! Although, if you check to see what the filter is (ie. Click the filter button and look to see it say 'equals') then clear the filter it has the same effect as before. Looks like this is a bug though.
I was able to reproduce the behavior that you are describing.
My suggestion for persist the filtering after clearing one of the default expressions is setting the condition option. For every column configured with default expression set the condition option to the condition set in the default expressipn. For example:
features: [ { name: "Filtering", columnSettings: [ { columnKey : "FirstName", condition: "doesNotContain", defaultExpressions: [ { expr: "B", cond: "doesNotContain", logic: 'AND' }, ] }, { columnKey: "LastName", condition: "equals", defaultExpressions: [ { expr: "S", cond: "equals", logic: 'AND' }, ] } ] } ]
Attached you will find my modified sample. Please test it on your side and let me know whether it helps you achieve your requirement.
5008.igGridFilteringSampleModified.zip
This achieves the same effect from before. The filter is applied correctly, and then when I clear the 'name' filter, the 'status' filter goes from 'doesNotContain' to 'equals'. I also noticed that even though the filters are technically working correctly, the filter type dropdown says 'equals' on both even though it's working as 'doesNotContain' for the status column.
Also when I use just one of the filters, it works perfectly.
Thank you for posting in our community.
By design, when you would like to set an initial filtering conditions the defaultExpressions options should be used. This option sets the initial filtering expressions and if set these conditions are going to be applied on initialization together with the present conditions. For example:
features: [ { name: "Filtering", columnSettings: [ { columnKey : "Status", defaultExpressions: [ { expr: "Closed", cond: "doesNotContain", logic: 'AND' }, ] }, { columnKey: "Name", defaultExpressions: [ { expr: "Joe", cond: "equals", logic: 'AND' }, ] } ] } ]
Setting filtering expressions on rendered event is not going to work as per your expectation because the event is fired only once when the grid is being initialized and it is not going to be fired when the grid is rebound to its data.
Please test my suggestion on your side and let me know whether it helps you achieve your requirement.