PDA

View Full Version : Trouble creating myFieldSet (extending from FieldSet)



RodS1967
7 Mar 2012, 12:18 PM
I did something like this previously so I didn't think this would be complicated at all. For some reason, I just can't make this work and I could really use a second set of eyes on my code. I'm probably missing something very obvious to a more experienced eye. What I am trying to do is replace a fieldset definition with a reusable "class". I have taken a fieldset right out of a tab which I have successfully created and tried to encapsulate it so I can reuse the fieldset in other areas of my application. I will include the tab as well as my attempt to encapsulate it in the code samples below. I am including the "class" in the requires clause. The error I am getting is:

items is undefined
len = items.length, ext-all.debug.js (line 72547)


{
xtype: 'tabpanel',
region: 'center',
items: [
{
title: 'Notification',
items: [
/*{
xtype: 'fieldset',
border: 'none',
items: [
{
xtype: 'textfield',
fieldLabel: 'Email Account',
value : record.get('email_account')
},
{
xtype: 'checkbox',
boxLabel: 'subscribe To Newsletter',
checked: (record.get('SUBSCRIBED') == 'Y')
}
]
}*/
{
xtype: 'myfieldset',
emailAccount: record.get('email_account'),
subscribe: (record.get('SUBSCRIBED') == 'Y')
}
]
},


Below is my attempt to recreate what is commented out in the code above for reuse in multiple areas.


Ext.define('app.view.module.utility.myFieldSet', {
extend: 'Ext.form.FieldSet',
alias : 'widget.myfieldset',
config: {
emailAccount: '',
subscribe: false
},

initComponent: function() {
Ext.applyIf(this, {
border: 'none',
items: [
{
xtype: 'textfield',
fieldLabel: 'Email Account',
value : this.emailAccount
},
{
xtype: 'checkbox',
boxLabel: 'Subscribe To Newsletter',
checked: this.subscribe
}
]
});
}
});


So... What am I overlooking?

Rod

mitchellsimoens
7 Mar 2012, 1:07 PM
Add this at the end of your initComponent call:


this.callParent();

RodS1967
7 Mar 2012, 2:05 PM
That was it. I actually had a colleage take a look at it while we were doing something else and he caught that. I knew I was just missing something stupid. Thanks for the reply.