-
6 Mar 2013 3:39 PM #1
Unanswered: Custom Component add items
Unanswered: Custom Component add items
Hi,
I am trying to add items to a custom component, but I cannot grab these items as a controller ref.
I would like to be able to get the items like:
Ext.Viewport.down('#myLaterAddedItem');
Here is how I add the items to the custom component:
What am I doing wrong?Code:Ext.define('Ext.mgd.DropDown', { extend: 'Ext.Component', xtype: 'buttondropdown', config: { itemsContainer: { cls: 'x-dropdown-container', items: [] }, items: [] }, getElementConfig: function () { return { reference: 'element', classList: ['x-unsized'] } }, applyItemsContainer: function (config) { return Ext.factory(config, Ext.Container, this.getItemsContainer()); }, updateItemsContainer: function (newContainer, oldContainer) { var me = this; if (newContainer) { newContainer.add(this.getItems()); newContainer.renderTo(this.element); newContainer.setParent(me); } else if (oldContainer) { oldContainer.destroy(); } }, initialize: function () { this.callParent(arguments); } });
-
8 Mar 2013 6:23 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
Your code, newContainer is not a child of container so Ext.Viewport.down will not find it.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Mar 2013 7:32 AM #3
How do I make it a child?
With 'applyItemsContainer' I made it a container itself.
With 'newContainer.add(this.getItems()); and 'newContainer.renderTo(this.element); I thought I made it a child. So what am I missing?
Do I have to extend Container instead of Component?
As I am using a template, can I still add the newContainer to the templat?
-
8 Mar 2013 7:43 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
This is what breaks it:
newContainer is not added to a container, it is just rendered to it. Sencha Touch isn't a DOM lib, it's focused on a component structure.Code:newContainer.renderTo(this.element);
Ext.mgd.DropDown extends Ext.Component so you would have to change it to extend Ext.Container and replace that renderTo call to be:
Code:this.add(newContainer);
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Mar 2013 7:58 AM #5
Still have an open end:
I am using a 'template' with a reference (e.g. innerElement) in there.
Now I would like to have the the newContainer being rendered to this.innerElement.
That way I get the structure:
Is that possible?Code:template: [ { reference: 'elementButton' }, { reference: 'element', children: [ { reference: 'innerElement' <have the newContainer being added here> } } ]
Do I have to wrap it?


Reply With Quote