ag-grid gridApi.setFilterModel() model with multip

2019-08-02 05:56发布

问题:

I want to filter my table based on a set of rules. I found that this was possible to do via filtermodels and conditions. I tried to stack conditions but that doesn't seem to work. e.g.

This works

Filter = {
    columnName: {
        condition1 : {
            type: 'contains',
            filter: 'searchstring1',
        },
        operator: 'AND',
        condition2 : {
            type: 'contains',
            filter: 'searchstring2',
        },
    },
};

This does not work.

Filter = {
    columnName: {
      condition1 : {
        condition1 : {
          type: 'contains',
          filter: 'searchstring1',
        },
        operator: 'AND',
        condition2 : {
          type: 'contains',
          filter: 'searchstring2',
        },
      },
      operator: 'OR',
      condition2: {
        type: 'contains',
        filter: 'searchstring3
      }
    }
  };

Any suggestions or work arounds for what I'm trying to acheive? I'm interested in stacking them so that I can have like perhaps 4 conditions1.

回答1:

I have the same problem, after inspecting the ag-grid sources I have found that this is not currently possible - the condition1 and condition2 are hardcoded.

My workaround is to create a hidden column of boolean type containing the result of these multiple conditions with value computed on the back-end side and filter on it.