1

I need to update/refresh Ag-Grid table from HeadRenderer and CellRenderer. For instance i have a button in CellRenderer and when this button is pressed. The table is refreshed.

const HeaderRenderer = (values) => {
        return (
     <>
      <Button
        onClick={ (e) =>
         {
           //code which redraws Ag-Grid tables
          }
        }
      />
    </>
   );
}

Although i cannot find any documentation how to do it from CellRenderers. Theoretically i should use gridApi.refreshCells but when i use it in CellRenderer and HeadRenderer those api are unfefined. Even it is defined in onGridReady. I was thinking to update it with values params. I think it has to be possible but i didn't find any functions for that? enter image description here Does anyone knows is it possible to do with values params from CellRenderer ?

Vlad
  • 419
  • 1
  • 10
  • 21

1 Answers1

0

You should be able to access the grid api from the cell renderer params.

Try:

const HeaderRenderer = (values) => {
  return (
    <>
      <Button
        onClick={(e) => {
          values.api.refreshCells();
        }}
      />
    </>
  );
};
  • Thank you for answer, but unfortunately it doesnt work – Vlad Dec 10 '21 at 08:24
  • Maybe try values.api.redrawRows(). Does that work? Why are you refreshing? – wnba_youngboy Dec 10 '21 at 16:38
  • Yes, i tried that also. Unfortunatelly it didn't work. Table just flashed for a second, but it still shows old unupdated data. And cell renderers as well show previous values like they wasn't even called. I need to refresh table because i have a column with cell renderers each holds button. And when HeadeRenderer is clicked the buttons in CellRednerers should change its color. – Vlad Dec 12 '21 at 19:41