Search code examples
angularag-gridag-grid-angular

Find out row index by searching in column in ag grid


I need to find the newly submitted student record by name in ag grid in specific column and pass the row id in flashCell method to highlight the new entry

  flashNewStudentRecord(rowIndex: number) {
    var rowNode1 = this.gridApi.getDisplayedRowAtIndex(rowIndex);
    this.gridApi.flashCells({
      rowNodes: [rowNode1],
    });
  }

now I have to search the student name in the client side data in column 'Student Name ' and get the row Index to pass it in above method , any suggestion how to achieve that

Cant search through my data source for the grid as its async , and its behaving weird


Solution

  • You can do this one way from the cellRenderFramework. there you can get the rowIndex from the params.

    here is an example :

     cellRendererFramework: (params) => {
         if(params.column?.columnId === "yourExactcolumnYouWantToTestOn"){
            if(prams.value ==="yourValueToTestOn"){
              //call your flash function, or the best would be to delay it, using setTimeOut
              flashNewStudentRecord(params.rowIndex)
            }
         }
         return <AgGridCellRenderer>         
                </AgGridCellRenderer>
     },