View Full Version : Silly question regarding callParent

21 Jan 2013, 7:37 AM
I wanted to experiment with the buildQuery method of Ext.ux.grid.FiltersFeature so I coded up this block of code when I defined the feature to be applied to my grid:

Inside of my grids 'initComponent method':

this.features = [
ftype: 'filters',
buildQuery: function(filters) {
console.log('build filter query');

I was surprised when I ran the code to get an exception on the 'this.callParent(arguments)' line for a

Uncaught Error: this.callParent() was called but there's no such method (onBeforeLoad) found in the parent class (Ext.grid.feature.Feature)

I thought it was odd even though I was in the buildQuery method, the callParent was working inside of the on BeforeLoad. I could see from the walkback that I was in fact in side of the onBeforeLoad method which had made a call to the buildQuery method, but why did callParent execute in the context of onBeforeLoad instead of buildQuery?

If I really wanted to call the original buildQuery method of Ext.ux.grid.FiltersFeature, what would be the way to do it? Is the only way to create an explicit subclass of Ext.ux.grid.FiltersFeature instead of trying to use this literal object approach?


Here's another thing I don't understand. When I debug the creation of the filter query, I see that my version of 'buildQuery' is executed and then the default version of 'buildQuery' is executed' It seems that my buildQuery isn't really overriding anything. The buildQuery method is executed in the FilterFeatures 'onBeforeLoad' handler which seems to be getting called twice, once with my change and once with the default configuration. Don't really understand why.



21 Jan 2013, 4:28 PM
Not sure about the specifics of this case but in general...

You cannot use callParent with an 'inline override'. It can only be used for a proper subclass declared with Ext.define.

There is one exception. For components you can use xhooks to do an 'inline override'. Do a forum search for xhooks if you want to know more about that, but it isn't relevant to a grid feature.

However, there's nothing to stop you from overriding a method like this if you don't mind calling the superclass method directly rather than using callParent. Something like:

Ext.ux.grid.FiltersFeature.prototype.buildQuery.apply(this, arguments);

22 Jan 2013, 5:49 AM
Thanks for the information. I suspected that I couldn't using 'callParent' in an inline definition but I thought I would give it a try. Your suggestion on how to call the parent class from an inline definition makes sense.

Thanks again.