I am using an angular-kendo-grid (version 6.14.5) in angular 10.0.3 with a kendoGridCellTemplate to show details.
<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. this should never happen!
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 the row with the 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?