Search code examples
reactjsag-gridag-grid-react

Aggrid refresh after state of rowGroupPanelShow changed


After changing rowGroupPanelShow from "always" to "never" group panel top doest hide. Is there any refreshView method i need to call from Grid instance ?

Code

this.setState({ rowGroupPanelShow: 'never' });

Solution

  • One easy way to get what you want quickly is to hide that component via css. Remember to provide a unique id for your table so you can find the exact component to toggle visibility

    Setup

    const showRowGroupPanel = () => {
      const el = document.querySelector(`#myTableId .ag-column-drop-wrapper`);
      el.style.display = "";
    };
    const hideRowGroupPanel = () => {
      const el = document.querySelector(`#myTableId .ag-column-drop-wrapper`);
      el.style.display = "none";
    };
    
    ...
    
    <button onClick={showRowGroupPanel}>Show</button>
    <button onClick={hideRowGroupPanel}>Hide</button>
    <div
      style={{ height: "100%", width: "100%" }}
      className="ag-theme-balham"
      id="myTableId"
    >
      <AgGridReact {...}/>
    </div>
    

    Live Example

    Edit AgGrid Toggle Row Group Panel