Programmatically filter on one column with multiple values

I want to programmatically filter a Gantt chart based on a single column with multiple values using an "OR". Is this possible? I found an old solution using a `filterContent` function on the Gantt chart, but I do not see that function on the current version.  The old solution I found is here: https://www.syncfusion.com/forums/reply/139629.

I tried this but it only filtered on the final value in the array:
```
names.forEach((f, index) => {
if (index === names.length - 1) {
this.chart.filterByColumn('name', 'equal', f);
} else {
this.chart.filterByColumn('name', 'equal', f, 'or');
}
});

3 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team March 10, 2021 02:56 PM UTC

Hi Andrew, 
 
Thank you for contacting Syncfusion support. 
 
We can filter multiple values programmatically by using the filterSettings.columns property. The following code snippets demonstrate the solution. 
 
App.component.ts 
this.filterSettings = { 
      columns: [ 
        { 
          field: "TaskName", 
          matchCase: false, 
          operator: "startswith", 
          predicate: "and", 
          value: "Reached" 
        }, 
        { 
          field: "TaskID", 
          matchCase: false, 
          operator: "equal", 
          predicate: "and", 
          value: 9 
        } 
      ] 
    }; 
  } 
 
We have prepared a sample for your reference. 
 
In order to know more about filtering in Gantt, please refer our Online Documentation and Samples. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



AT Andrew Tarr March 10, 2021 06:18 PM UTC

I'm looking to filter on the same column. Given your example, is something like this possible?:

this.filterSettings = {
columns: [
{
field: "TaskName",
matchCase: false,
operator: "startswith",
predicate: "or",
value: "Reached"
},
{
field: "TaskName",
matchCase: false,
operator: "equal",
predicate: "and",
value: "Launch"
}
]
};


MS Monisha Sivanthilingam Syncfusion Team March 11, 2021 07:17 AM UTC

Hi Andrew, 
 
We can filter the same column based on multiple values using the filterSettings.columns property. The following code snippets demonstrate the solution. 
 
App.component.ts 
this.filterSettings = { 
      columns: [ 
        { 
          field: "TaskName", 
          matchCase: false, 
          operator: "startswith", 
          predicate: "and", 
          value: "Reached" 
        }, 
        { 
          field: "TaskName", 
          matchCase: false, 
          operator: "contains", 
          predicate: "and", 
          value: "spanning" 
        } 
      ] 
    }; 
 
We have also prepared a sample for your reference. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Marked as answer
Loader.
Up arrow icon