ag-gridag-grid-angularag-grid-reactag-grid-vue

ag-grid React run on every render


I want to re-run

            headerComponentFramework: (params) => {
                console.log('xxx');
            },

every single time the data value changes

      <AgGridReact
                defaultColDef={defaultColDef}
                rowData={data}
                columnDefs={columnDefs}
            />


Solution

  • To refresh a header, you can use the Grid API method refreshHeader.

    To refresh a header when the data changes, you can listen to the following Grid Events: onCellValueChanged, onRowDataChanged and onRowDataUpdated.

    See this implemented in the following plunkr.

      const rowDataChanged = (params) => {
        console.log('rowDataChanged');
        params.api.refreshHeader();
      };
    
      const rowDataUpdated = (params) => {
        console.log('rowDataUpdated');
        params.api.refreshHeader();
      };
    
      const cellValueChanged = (params) => {
        console.log('cellValueChanged');
        params.api.refreshHeader();
      };