PDA

View Full Version : How do I remove the "loading" mask from a store on exception ?



yyogev
26 Aug 2012, 6:22 AM
I have a grid panel where in some cases the load errors might return an error message. I have found that I can catch this in the 'exception' event in the proxy.
However, I could not figure out how I can unmask the grid so the "loading" mask will disappear when the error is encountered.

Any help will be appreciated.

yyogev
26 Aug 2012, 9:35 PM
Ext.getCmp("my_grid").getView().setLoading(false);

makana
26 Aug 2012, 11:02 PM
There's one line in ExtJS code that shows that Sencha thought about hiding the mask on exceptions.

bindStore in LoadMask.js


me.mon(store, {
scope: me,
beforeload: me.onBeforeLoad,
load: me.onLoad,
exception: me.onLoad
});


However, the exception event on stores is never fired. The code exists in all versions from 4.0.0 till 4.1.1.
I use this override to bubble the exception event of a proxy to the store.


Ext4.define('Ext.override.data.AbstractStore', {
override: 'Ext.data.AbstractStore',

constructor: function()
{
this.callParent(arguments);
// exception-Event hinzufügen
this.addEvents('exception');
},
setProxy: function(proxy)
{
var me = this;
// bei altem Proxy Listener entfernen
if (me.proxy && me.proxy.isProxy)
me.mun(me.proxy, 'exception', me.onProxyException, me);

proxy = me.callParent(arguments);

me.mon(proxy, 'exception', me.onProxyException, me);
return proxy;
},
onProxyException: function()
{
var args = Ext4.Array.from(arguments);
args.unshift('exception');
this.fireEvent.apply(this, args);
}
});

yyogev
26 Aug 2012, 11:46 PM
Perhaps the coupling of onLoad with the 'exception' event was supposed to do the hiding of the 'loading' mask ?

makana
26 Aug 2012, 11:58 PM
Yes, that's what I mean. I think they intent to hide the mask (that is what onLoad does) on exceptions. but they don't bubble the exception event from proxy to the store, so there's no exception event on stores. The mentioned override is to bind the exception event to the store.