PDA

View Full Version : How to call parent class overridden method in overriding method



DineshGudikandula
21 Jan 2013, 8:37 AM
Hi all...

I got lots of errors while calling the parent class overridden method..

Sample Code :





Ext.define('estore.view.SliderButton', {
extend: 'Ext.CycleButton',
alias : 'widget.sliderbutton',
requires:['estore.view.SliderMenu'],
initComponent : function(){
this.addEvents(
"change",
"sliderchange"
);


if(this.changeHandler){
this.on('change', this.changeHandler, this.scope||this);
delete this.changeHandler;
}


this.itemCount = this.items.length;


this.menu = {cls:'x-cycle-menu', items:[], buttonLink: this};

var checked;
for(var i = 0, len = this.itemCount; i < len; i++){

var item = this.items[i];
item.group = item.group || this.id;
item.itemIndex = i;
item.checkHandler = this.checkHandler;
item.scope = this;
item.checked = item.checked || false;
this.menu.items.push(item);
if(item.checked){
checked = item;
}
}
this.menu = new estore.view.SliderMenu(this.menu);
this.setActiveItem(checked, true);
this.on('click', this.toggleSelected, this);
this.callParent();
},
setActiveItem : function(item, suppressEvent){

//Here showing error

// Ext.CycleButton.prototype.setActiveItem.call(this,item,suppressEvent);
Ext.CycleButton.superclass.setActiveItem.call(this,item,suppressEvent);
// Ext.CycleButton.superclass.setActiveItem.apply(this,item,suppressEvent);
//this.superclass.setActiveItem.call(this,item,suppressEvent);
//estore.view.SliderButtonsuperclass.setActiveItem.call(this,item,suppressEvent);
// this.callParent(arguments);
if (this.menu.slider)
this.menu.selectSliderValue(item);
else {
this.menu.sliderValueChange(this, item);
this.menu.defaultSliderValue = item;
}
}
});




Thanks in advance.....

skirtle
21 Jan 2013, 4:19 PM
The correct version is:


this.callParent(arguments);

though some of the other versions should work too.

Could you post the stacktrace for the error that you're getting? I suspect the problem has nothing to do with how you're calling the superclass.

You're doing all sorts of highly worrying looking things there. The way you're building that menu is fraught with danger, especially the bits where it appears to have custom children. I wouldn't feel confident calling setActiveItem in initComponent before you've called the superclass initComponent either.

I suggest that you study the code for Cycle button carefully to understand the full ramifications of what you're doing.