0
votes

Based on this post: How can I filter results based on multiple selections from dropdown?

, what if the two selected values are from columns that not next to each other?

For example if the two drop down are 'name' and 'symbol'?

Does the dataSource.filter take wildcard as input? Like 'Hydrogen*H'

If not, how can we implement this function so that it can perform AND operator?

1
put some code on ur question for batter understanding of ur question.CodeChanger

1 Answers

1
votes

just use a function like

  customFiltered() {
    return (data, filter) => {
      if (this.name && this.symbol)
        return data.name == this.name && data.symbol == this.symbol
      if (this.name)
        return data.name == this.name
      if (this.symbol)
        return data.symbol == this.symbol
      return true
    }
  }

Then you only need

this.dataSource.filterPredicate =this.customFiltered();

where your variable this.name and this.symbol are [(ngModel)] of your select

You can see in stackblitz