Posted 9 September 2020, 8:44 am EST
Dear Wijmo team,
I’m using Angular to render Flexgrid. I have a variable called selectedItem that I use to display data of a single item from the grid in a detail component next to the grid.
When deleting a row from the grid, the selectedItem isn’t updated. I wonder why.
Delete method
async delete(){
if (this.selectedItem.id){
let result = await this.api.deleteLi(this.selectedItem.id);
let rowData = this.data.sourceCollection.find(k=>k.id===this.selectedItem.id);
this.data.remove(rowData);
} else if (this.selectedItem.guid){
let rowData = this.data.sourceCollection.find(k=>k.guid===this.selectedItem.guid);
this.data.remove(rowData);
}
if (this.data.sourceCollection.length===0){
this.selectedItem={};
}
this.data.refresh();
this.checkChanges();
}
Selection Changed Method
async selectionChanged(e: CellRangeEventArgs) {
if (this.flexdata.rows[e.range.row]){
this.selectedItem=this.flexdata.rows[e.range.row].dataItem;
this.checkChanges();
}
}
To me it seems that the selectionChanged method isn’t triggered when I delete a row. Is there a way to manually trigger the selectionChanged method?
Best regards
Moritz