79459791

Date: 2025-02-22 14:58:16
Score: 0.5
Natty:
Report link

Highlight the row on scroll

highlightedCells: { [key: string]: boolean } = {};

Apply in Ag-grid column Def

cellClassRules: {enter code here
  'hightlighted-cell': (params: any) =>
     this.highlightedCells[`${params.rowIndex}-${params.column.colId}`],
   },

Below function called on click of Cell of Row (R1C2)

highlightAndScrollToCell(rowIndex: any, colKey: any) {
    this.highlightedRowIndex = rowIndex;
    this.highlightedColumnKey = colKey;
   if (this.gridParams && rowIndex !== null && colKey) {
      const cellKey = `${rowIndex}-${colKey}`;
      this.highlightedCells[cellKey] = true;
      this.gridParams.api.refreshCells({ force: true });
      this.gridParams.api.ensureIndexVisible(rowIndex, 'middle');
      this.gridParams.api.ensureColumnVisible(colKey);
      this.gridParams.api.setFocusedCell(rowIndex, colKey);
    }
 } 
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: priyanka