Fares Omrani
Fares Omrani

Reputation: 255

deselect rows of a grid in Extjs 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

Upvotes: 3

Views: 16536

Answers (2)

AMember
AMember

Reputation: 3057

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()
      }
   }
})

Upvotes: 8

Vinay
Vinay

Reputation: 743

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()
      }
   }
})

Upvotes: 10

Related Questions