afterrender: function(obj)
{
var store = THIS.deployAnalyticsGridStore;
var model = THIS.deployAnalyticsGridView.selModel;
model.suspendEvents();
store.load(
{
scope : this,
params : {
method : 'getDevices',
eventId : 'nativemethodcall',
subEventId : ''
},
callback: function(records, operation, success)
{
model.suspendEvents();
// console.log("The call back is called");
//var model = THIS.deployAnalyticsGridView.selModel;
// model.suspendEvents();
var count = store.getTotalCount();
for (var i = 0; i < count; i++) {
var record = store.getAt(i);
if(record != undefined)
{
if (record.get('analyticsEnabled') == true) {
model.selectRange(i, i, true);
}
}
}
model.resumeEvents();
}
});
}
}
After the UI is rendered , I have listeners in checkbox selection model which will be called when the user checks or unchecks the checkbox and updates the model respectively. Code
listeners :
{
deselect: function(model, record, index)
//alert('deselect called');
{
var store = THIS.deployAnalyticsGridStore;
var record = store.getAt(index);
record.set("analyticsEnabled", false);
THIS.deployAnalyticsGridView.refresh();
},
select: function(model, record, index)
{
//alert('select called');
var store = THIS.deployAnalyticsGridStore;
var record = store.getAt(index);
record.set("analyticsEnabled", true);
THIS.deployAnalyticsGridView.refresh();
},
selectionchange: function(model, selected, eOpts)
{
//alert('selection called');
var count = THIS.deployAnalyticsGridStore.getTotalCount();
var selcount = selected.length;
if (selcount == 0)
{
model.deselectAll(true);
var store = THIS.deployAnalyticsGridStore;
var count = store.getTotalCount();
for (var i = 0; i < count; i++) {
var record = store.getAt(i);
if (record.get('analyticsEnabled') == true)
{
record.set("analyticsEnabled", false);
}
}
THIS.deployAnalyticsGridView.refresh();
} else if (selcount == count)
{
model.selectAll(true);
var store = THIS.deployAnalyticsGridStore;
var count = store.getTotalCount();
for (var i = 0; i < count; i++)
{
var record = store.getAt(i);
if (record.get('analyticsEnabled') == false)
{
record.set("analyticsEnabled", true);
}
}
THIS.deployAnalyticsGridView.refresh();
}
}
}
}),
The problem I am facing is that, the selection checkbox model listeners(select & selection change ) function gets called when the call back functions checks the checkbox during the store load .I have suspended the model event like this var model = THIS.GridView.selModel; model.suspendEvents(); during the call back, but it doesn't seems to work .Please help.
Aucun commentaire:
Enregistrer un commentaire