How to refresh/update Ag-Grid from CellRenderer and HeadRenderers

Viewed 800

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 ?

1 Answers

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();
        }}
      />
    </>
  );
};
Related