1
votes

I am using editType as "fullRow" and cellRenderer for Edit,Delete buttons. this is working well if we not sort the grid. after sorting or deletion of some rows it is giving wrong row indexes.

this.gridOptions.api.updateRowData({ remove: event.selectedData });

i am using above code for deleting row. but after sorting grid it is not working.

while updating rows i am getting rowNode as undefined after sorting.please see below code for updating a row.

let rowNode = this.params.api.getRowNode(rowIndex);
            rowNode.setData(previousData);

my understanding was it is giving deleted rowindex thats why we are getting rowNode as undefined .please help to fix this this.

1

1 Answers

0
votes

This a very old question but I am posting it for people who may face this issue now.

I have recently resolved the a issue in a project.

follow the steps below

  1. <ag-grid (sortChanged)="onSortChanged($event)"></ag-grid> sortChanged will only be called when the user is trying to sort the grid.

  2. As we have a hook now we can modify the rowIndex parameter manually by iterating over the params

    onSortChanged(params){ params.api.forEachNode((rowNode,index)=>{ rowNode.rowIndex = index; }); }

This should update the rowindex.

You may have to refresh the grid if it is not updating the returned rowindex.One walk around for that is manually start the editing of any index and then stop it.