Data disappears from mat table when grouping

Viewed 351

Rows disappear from mat-table when the search bar is put on focus and then the table is grouped.filtereddata property of datasource becomes empty when i group it. When filtered or put focus on search bar, the table gets filtered but then if I group or ungroup it, the rows of mat table disappear.

Here is the stackblitz example https://stackblitz.com/edit/%2Fapp.component.ts

1 Answers

The reason why your rows "disappear" is because you change your filter predicate when you focus the search field:

(focus)="setupFilter()"

Then, when you group rows (i.e. in your groupBy(event, column) method), you apply a new filter value:

this.dataSource.filter = performance.now().toString();

Then, your predicate returns false for all the rows, which means they get filtered out.

Honestly not sure what you're trying to achieve here with all that filter re-applying and predicate swapping, but that's the reason why your rows are not rendered.

Related