0

How can I filter a single column values from a material table ?

FilterChange(event:Event)
{  
const fillvalue=(event.target as HTMLInputElement).value;  
this.dataSource.filter = fillvalue;
}

This is my function, I need to call the function when the text is entered and click the search button in the form, I'm using <mat-form-field> for the input. Here event is the value passed after the text is entered in the input field.

1 Answers1

0

Use filter predicate to create your own custom filter function

this.dataSource.filterPredicate = (
  data: PeriodicElement,
  filter: string
): boolean =>
  data.weight.toString().indexOf(filter) === -1 ? false : true;

here, weight is the column name

Mr. Stash
  • 2,940
  • 3
  • 10
  • 24