1

Is there a way to update current cell's style dynamically within onCellKeyDown callback? I'm trying to access current cell using grid API but no luck so far.

I've applied style but it appears only when the cell loses its focus.

onCellKeyDown={e => {
          const cell = e.api.getFocusedCell();
          const { colId } = cell.column;
          const selector = `[col-id=${colId}]`;
          cell.column.colDef.cellStyle = {
            color: "red",
            fontWeight: "550",
            border: "3px solid red !important"
          };

        }}
StangSpree
  • 421
  • 1
  • 5
  • 22
  • have you refreshed cell using params.api.refreshCells(); after applying cell style? check this answer for a similar question - https://stackoverflow.com/a/62249386/983929 – Pratik Bhat Jul 03 '20 at 16:53
  • I did in the following way: gridApi.refreshCells({ columns: ["date"] }); That did not help either. – StangSpree Jul 03 '20 at 17:03
  • in your case you need to use force:true I think gridApi.refreshCells({ force:true, columns: ["date"] }); – Pratik Bhat Jul 03 '20 at 17:05
  • My use case is slightly different. I would like to apply red border to cell that is currently in focus not to the entire column. – StangSpree Jul 03 '20 at 17:12
  • not sure if you ve taken a look at the answer, but the answer in the linked question is changing styles for a single cell only and not entire column – Pratik Bhat Jul 03 '20 at 17:17
  • I did. If you could provide a working example that would be great. If you notice, I have copied the snippet of my current code. – StangSpree Jul 03 '20 at 17:24
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217175/discussion-between-stangspree-and-pratik-bhat). – StangSpree Jul 03 '20 at 17:25

0 Answers0