Components: [Table] When predicate should evaluate on each data emit

Created on 23 Jan 2018  路  7Comments  路  Source: angular/components

The table uses the row when predicate to determine which row template to use for a piece of data, but only once when inserting a new row.

This should be evaluated on each emit to confirm that data objects match to the right row template.

https://stackblitz.com/edit/angular-bgzmrf-tbx3dm?file=app%2Ftable-basic-example.ts

P2 cdtable materiatable

Most helpful comment

OH MY GOD!!!! I cannot believe I wasted 2 hours debugging this case which turns out to be a bug. Are there any plans to fix this or maybe there's a workaround to the issue which I haven't thought of?

In our case, we have an edit button inside the table row. When clicked, the button calls a function which sets the index of the row being edited and that should in theory open the details row, but in practice doesn't (like with your stackblitz example).

All 7 comments

OH MY GOD!!!! I cannot believe I wasted 2 hours debugging this case which turns out to be a bug. Are there any plans to fix this or maybe there's a workaround to the issue which I haven't thought of?

In our case, we have an edit button inside the table row. When clicked, the button calls a function which sets the index of the row being edited and that should in theory open the details row, but in practice doesn't (like with your stackblitz example).

Any progress on this one? As a workaround I re-assign my datasource

Would like to know this as well. Currently experiencing that bug

Any update on this one? It might be an idea to either let the when - function return a boolean (which is not re-evaluated, as it is implemented right now), or return an observable, which will trigger changes in the table if the observable emits a boolean change, maybe even marked with | async ?

Is this to be resolved in the upcoming version 8?

In my case I wanted to implement an infinite scroll, adding new rows at the bottom, but because because of this bug the new rows get broken indexes.

Apart from the missing id="index" attribute I also get the missing class="ng-star-inserted", which means the new rows were ignored my material.

Screenshot 2019-05-06 at 16 46 38

A workaround for this issue is to declare:
@ViewChild(MatTable, {static: false} table: MatTable<any>;

And then use:
this.table.renderRows()
whenever you update the property that when depends on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shlomiassaf picture shlomiassaf  路  3Comments

alanpurple picture alanpurple  路  3Comments

RoxKilly picture RoxKilly  路  3Comments

michaelb-01 picture michaelb-01  路  3Comments

3mp3ri0r picture 3mp3ri0r  路  3Comments