PDA

View Full Version : CheckboxModel deselection difference



ralfius
18 Oct 2012, 6:09 AM
Hello,
I have a grid with Ext.selection.CheckboxModel.

Ext.define('MyGrid',
{
extend: 'Ext.grid.Panel',
store: Ext.create('MyStore'),
columns: [{
header: 'Code',
dataIndex: 'Code'
},{
header: 'Name',
dataIndex: 'Name'
}],
initComponent: function(){
this.selModel = Ext.create("Ext.selection.CheckboxModel",{
checkOnly : true,
listeners: {
select: function(row, record, index, eOpts){
myBusinessService.select(record);
},
deselect: function(row, record, index, eOpts){
myBusinessService.deselect(record);
}
}
});
this.callParent(arguments);
}
});

I have to make some actions when user selects or deselects some record in this grid. In some cases the store for this grid is reloading. In ExtJS 4.1.1 before store is loaded there happens deselection of all selected item that makes deselect event for Checkboxmodel fired. But I just want to process user selection\deselection. How can I distinguish deselection via store reloading and user deselection? Thanks!

metalinspired
18 Oct 2012, 7:08 AM
I couldn't quite figure out what are you saying but pruneRemoved (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.selection.Model-cfg-pruneRemoved) might be of some help maybe.

ralfius
19 Oct 2012, 5:33 AM
I found the solution. In order to prevent deselecting all selected rows in grid with CheckboxModel when store is reloading, before store loading there should be done store.removeAll(). After this you can use store.load(). Deselect event isn't fired.