ag-grid gridApi.setFilterModel() model with multiple conditions [angular6]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 08:58:40

问题


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.



来源:https://stackoverflow.com/questions/52174160/ag-grid-gridapi-setfiltermodel-model-with-multiple-conditions-angular6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!