PDA

View Full Version : Inheriting items in parent classes



infernoz
4 Jun 2012, 7:39 AM
Hello,

I am aware that if you extend a class, the parents class' functions and properties will be available to the child class.

What about items that are added in the dockedItems/items config if the parent and child are panels? How can the child automatically inherit the child elements without having to manually enter them into the child? Will this work by default in ExtJS 4 (I'm using 4.1)

Would it be possible to see an example of this setup?

Thanks,

infernoz

mitchellsimoens
7 Jun 2012, 1:24 PM
If class A has the items property set to an array of config objects and class B extends class A and does not have the items property set, it will inherit the items array from class A

kivras
1 Nov 2012, 5:28 PM
I have the exact same question but , what happens if i need to inherit class A items PLUS class B items.
So when defining lets say:

A-> Items: [{xtype:textfield}] ,

B->Items:[{xtype:button}],

B would have actually
items:[
{xtype:textfield},
{xtype:button}
]

Thank you!

skirtle
3 Nov 2012, 1:20 AM
One way is to add a template method to build the items config. See:

http://skirtlesden.com/articles/config-objects-on-the-prototype

kivras
6 Nov 2012, 5:45 AM
Great Article!! Exactly what i was searching for thank you!