I am using Material Table on my Angular 7 project.
I have a table that displays several objects.
Each object has a property 'number of promotions' and i would like to filter this table using numbers ranges (under 5, from 6 to 10, from 11 to 20, more than 20).
Here is an example of the dataSource.filterPredicate I used to have custom filters on my table but i don't get how to manage the one i explained earlier...
this.dataSource.filterPredicate = (data: Store, filter: string) => {
switch (this.filterCriteria) {
case 'approval':
if (filter === 'null' || filter === '') {
return (data);
} else {
return (data.approval.trim().toLowerCase().indexOf(filter) !== -1
);
}
I did manage to solve my problem, and i was very very very simple. -_-'
I just had a case to my switch with the correct filter on my dataSource.filterPredicate.
case 'promotion':
if (filter === 'null' || filter === '') {
return (data);
} else {
switch(filter){
case '5':
return (data.total_promotions <= 5);
case '10':
return (data.total_promotions > 5 && data.total_promotions <= 10);
}
}
}