1

--------------------- Solution ---------------------------

I did a workaround of having to callParent inside my code,

 var expandFieldOverride = function(event)
{
    //event: collapse, false / expand, true 
    var fieldset = this; 
    var arguments = [event]; 

    if(!fieldset.readyToExpand){            
        Ext.each(profilesPanel.items.items, function(panel, i)
        {       
            if (panel.isProfilePanel)
            {
                    console.log(event); 
                    var field = panel.down('profileform[title=Standard Configuration]').down('fieldset[name='+fieldset.name+']');
                    field.readyToExpand = true; 
                    field.setExpanded(event); 
            }           
        });
    }
    this.callParent(arguments); 
    fieldset.readyToExpand = false; 
}

-------------------------Initial Problem-------------------------------

I am using ExtJS 4.2.1 and I am trying to override the collapse and expand events of fieldsets. Using collapse and expand didn't work, so I had to directly override setExpanded(). I am trying to achieve the event that when one fieldset is collapsed in a profile panel, so is the other in the other profile panel, and vice versa.

 Ext.define('EcoCentral.Configuration.ThermostatProfiles.ProfileOptionsFieldSet',
{
    extend: 'Ext.form.FieldSet',
    setExpanded: expandFieldOverride,
    //expand: expandFieldOverride,
    //collapse: collapseFieldOverride,
    alias: 'widget.profilefieldset'

});

 var expandFieldOverride = function(event)
{
    //this.callParent(arguments);
    //event: collapse, false / expand, true 
    var fieldset = this; 
    var arguments = [event]; 

    Ext.each(profilesPanel.items.items, function(panel, i)
    {       
        if (panel.isProfilePanel)
        {
            var field = panel.down('profileform[title=Standard Configuration]').down('fieldset[name='+fieldset.name+']');
            console.log(field); 
            //field.callParent(arguments); 
            field.self.superclass.setExpanded.call(arguments); 
        }
        //this.callParent(arguments); 
    });
}

If I use 'this.callParent(arguments)' inside the code, I recieve 'Uncaught TypeError: Cannot read property 'superclass' of undefined '

I did some research and tried out this line of code 'field.self.superclass.setExpanded.call(arguments);' from which I recieve : 'Uncaught TypeError: Object # has no method 'addCls''

Which is a call inside of the setExpanded function in the source.

 setExpanded: function(expanded) {
    var me = this,
        checkboxCmp = me.checkboxCmp,
        operation = expanded ? 'expand' : 'collapse';

    if (!me.rendered || me.fireEvent('before' + operation, me) !== false) {
        expanded = !!expanded;

        if (checkboxCmp) {
            checkboxCmp.setValue(expanded);
        }

        if (expanded) {
            me.removeCls(me.baseCls + '-collapsed');
        } else {
            me.addCls(me.baseCls + '-collapsed');
        }
        me.collapsed = !expanded;
        if (expanded) {
            delete me.getHierarchyState().collapsed;
        } else {
            me.getHierarchyState().collapsed = true;
        }
        if (me.rendered) {
            // say explicitly we are not root because when we have a fixed/configured height
            // our ownerLayout would say we are root and so would not have it's height
            // updated since it's not included in the layout cycle
            me.updateLayout({ isRoot: false });
            me.fireEvent(operation, me);
        }
    }
    return me;
},

My fieldset is defined by xtype:

Alpenglow
  • 153
  • 1
  • 17

1 Answers1

0

You have to use apply. Call is the wrong function. Have a look at this:

What is the difference between call and apply?

Community
  • 1
  • 1
squirrel
  • 183
  • 1
  • 9
  • field.self.superclass.setExpanded.apply(arguments); I received the same error using apply. Is this what you were referring to? – Alpenglow Aug 14 '13 at 17:48