3

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

Fares Omrani
  • 255
  • 1
  • 4
  • 22

2 Answers2

10

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()
      }
   }
})
Vinay
  • 723
  • 9
  • 32
8

You should enable the toggle option for the button. here is an example:

new Ext.Button({
   enableToggle:true,
   toggleHandler:function(btn,state){
      var grid = Ext.getCmp(YOURGRIDID),
      if(state==true){
         grid.getSelectionModel().selectAll()
      }else{
         grid.getSelectionModel().clearSelections()
      }
   }
})
AMember
  • 3,037
  • 2
  • 33
  • 64