View Full Version : cannot listen beforeprefetch event

17 Oct 2011, 5:32 AM
I have this code in a store definition:

initComponent: function(){
this.addListener('beforeprefetch', this.onBeforePrefetch, this);
this.superclass.initComponent.call(this, arguments);

onBeforePrefetch: function(store,operation,options){

but function is not logging anything when the data is loaded into a grid using this store... anyhelp?

17 Oct 2011, 1:42 PM
Stores don't have an initComponent method. Only components have initComponent. Override the constructor instead.

Also, this line has some issues:

this.superclass.initComponent.call(this, arguments);

Firstly, it's a subclassing nightmare. If you subclass this store it'll get into an infinite loop because this.superclass.initComponent will refer to itself.

Secondly, you've used call with arguments. It should really be apply, not call. This point is moot though as initComponent doesn't take any arguments anyway.

Thirdly, the correct way to call a superclass's overridden implementation of a method in ExtJS 4 is:




In the case of initComponent I'd use the former as it doesn't take any arguments.