<
kendo-grid
#KendoGrid
[data]="gridSettings.gridView"
(...)
>
<
kendo-grid-column
field
=
"code"
title
=
"code"
>
(...)
<
ng-template
kendoGridCellTemplate let-dataItem>
<
details-component
[id]="dataItem.Id"
(onDelete)="onDelete($event)">
</
details-component
>
</
ng-template
>
(...)
</
kendo-grid
>
The details component has a "Remove" button that is supposed to remove all details for that master row. When the button is pressed, the 'onDelete()' event is emitted back to the masterComponent and the masterComponent removes the row from it's datasource.
onDelete(deletedRowId: number): void {
this
.rows =
this
.rows.filter(r => r.id !== deletedRowId.id);
this
.loadGridResult();
}
loadGridResult(): void {
this
.gridSettings.gridView = {
data: orderBy(
this
.rows,
this
.gridSettings.sort)
.slice(
this
.gridSettings.skip,
this
.gridSettings.skip +
this
.gridSettings.pageSize),
total:
this
.rows.length
};
}
On screen the row is removed from the table and the next row is expanded (I asume this happens since the row with this index used to be expanded), but the details for the already removed row are still shown. This means that now the table shows a row with incorrect details. The shown details do not belong to this row. I don't think this should ever happen!
The attached images show what I mean. First before any button is clicked an then after clicking on Remove in the details of row 2:
If the Remove button is clicked again the page crashes as it tries to remove something that was already removed. If any row with now corrupt details is collapsed and again expanded the correct details are loaded.
It seems like the details of row 2 are incorrectly kept in memory or something. Can I do something to solve that?
Can someone explain what is going on here and why this doesn't work as I expect? What can I do to fix this?
I asked the same question on SO here but did not get any response yet. Thanks in advance..