Search code examples
ag-gridag-grid-react

How to Unselect/ deselect all rows in a React AGGrid grid or reload the grid easily?


I have a React AGGrid grid with some rows and i can select a row/rows by clicking on a checkbox in a row. Anyway I need to deselect all checkbox/ checkboxes selected in rows when clicking on a button. How do I do this? Please help.

I tried this by using a setState and it didnt work. Please help.


Solution

  • Well its pretty straightforward. You can define couple of methods such as these:

    selectAllRows() {
      this.gridApi. selectAll();
    }
    
    deselectAllRows() {
      this.gridApi. selectAll();
    }
    

    and bind them to the buttons.

    You can refer other options here: Ag Grid React: Selection Events