Reputation: 255
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
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
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