PDA

View Full Version : Waiting message while removing records of a grid



marxan
29 Aug 2012, 5:09 AM
Hello,

I want to add a waiting message while I remove records from my grid.



removeRecord: function (c,record,index,e){
myGrid = Ext.getCmp('metrSeriesGridId');
myGrid.setLoading("Loading");

var store = Ext.getStore('NrrSeriesStore');
var toRemove = []; store.each(function (record) {
if (record.get('CODEFC') === valueToRemove) {
toRemove.push(record);
}
});
store.suspendEvents();
store.remove(toRemove);
store.resumeEvents();

myGrid.getView().refresh();

myGrid.setLoading(false);


If I leave the code like this, nothing happen.
If I remove the setLoafing(false); then I see the waiting message but it doesn't dissapear.

It also seems that the loading message comes only after I removed the records...

Anyone could help me?

Thanks

redraid
29 Aug 2012, 5:17 AM
Try this:


removeRecord: function (c,record,index,e){
var myGrid = Ext.getCmp('metrSeriesGridId'),
el = myGrid.getEl();

// show mask
el.mask('Removing records...');

var store = Ext.getStore('NrrSeriesStore');
var toRemove = []; store.each(function (record) {
if (record.get('CODEFC') === valueToRemove) {
toRemove.push(record);
}
});

store.suspendEvents();
store.remove(toRemove);
store.resumeEvents();
store.sync({
callback: function () {
el.unmask();
}
});

marxan
29 Aug 2012, 5:48 AM
Still the same problem, if I remove the callback function I see the message but it doesn't dissapear If I leave it no message appears.

redraid
29 Aug 2012, 5:57 AM
Replace
store.sync({
callback: function () {
el.unmask();
}
});
with:

Ext.Function.defer (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Function-method-defer)(function(){ el.unmask();}, 100);

marxan
29 Aug 2012, 6:23 AM
It works.

Thanks