deselect rows of a grid in Extjs 3

Fares Omrani picture Fares Omrani · Dec 5, 2011 · Viewed 15.9k times · Source

I have a grid and a button that makes me select all the rows of this grid (mygrid.getSelectionModel().selectAll()) But i want that when all the rows are selected and i click to this button it deselct all the rows. How can i do it ?

Thank you for helping

Answer

Vinay picture Vinay · Oct 15, 2013

instead of using clearSelections() use deselectAll() as the former is now deprecated.

new Ext.Button({
   enableToggle:true,
   toggleHandler:function(btn,state){
      var grid = Ext.getCmp(YOURGRIDID),
      if(state==true){
         grid.getSelectionModel().selectAll()
      }else{
         grid.getSelectionModel().deselectAll()
      }
   }
})