I was creating custom filters like this:
Code: Select all
<p-table #dt [value]="allSettings" [(selection)]="selectedSetting">
<ng-template pTemplate="caption">
<p-selectButton [options]="keyFilters" (onChange)="onChangeMyFunction($event, dt)"
[(ngModel)]="keyFilter"></p-selectButton>
</ng-template>
Code: Select all
@ViewChild('dt', {static: false}) ttable: Table;
ngOnInit() {
// This if I added in Angular 8 because this.ttable['filterConstraints'] because TypeError: Cannot set property 'containsNone' of undefined
// In Angular 7 it was working event without this.
if (!this.ttable['filterConstraints']) {
this.ttable['filterConstraints'] = [];
}
this.ttable['filterConstraints']['containsNone'] = function containsNone (value: string, filter: string[]): boolean {
console.log('ttable.filterConstraints.containsNone', value, filter);
const result = someBusinessLogic();
return result;
};
}
onChangeMyFunction(event: any, grid: Table) {
console.log('onChangeMyFunction() grid.filterConstraints = ', grid.filterConstraints);
const value = event === null ? null : event.value;
switch (value) {
case 'none':
grid.filter(['MONO_', 'YEXT_', 'BOOST_'], 'key', 'containsNone');
break;
default:
grid.reset();
break;
}
}
Code: Select all
onChangeMyFunction() grid.filterConstraints = [containsNone: f, containsAll: f]
core.js:6014 ERROR TypeError: filterConstraint is not a function
at Table.push../node_modules/primeng/components/table/table.js.Table._filter (table.js:887)
at table.js:830
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39679)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at invokeTask (zone-evergreen.js:465)
at ZoneTask.invoke (zone-evergreen.js:454)
at timer (zone-evergreen.js:2650)
Thank you very much for your support!
MM