Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
igGridFiltering reverts to 'Equals' once another filter is cleared
posted

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

Parents
No Data
Reply
  • 17590
    Offline posted

    Hello Erik,

    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.

Children