-
30 Jul 2012 4:15 AM #1
HELP: Render Component into HTML element (div etc.)
HELP: Render Component into HTML element (div etc.)
Hello,
How do I render an Ext Component (buttons etc.) into a normal HTML element? I've got an Ext.Container with a normal html table in it. I want to render an Ext.Button into the table. In Ext Js you can use the render() method, but I can't find any similar in Sencha Touch 2.
Code:Ext.create('Ext.Container', { html: [ '<table>', '<tr>', '<td>some data...</td>', '<td>' + Ext.create('Ext.Button', { text: 'Button' }) + '</td>', '</tr>', '</table>' ] });
Thanks!
-
1 Aug 2012 6:21 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Try using the renderTo config
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.
-
1 Aug 2012 8:48 AM #3
Can you do something like this then?
Code:var div = document.createElement('div'); Ext.create('Ext.Button', { text: 'Button', renderTo: div });
-
1 Aug 2012 7:11 PM #4Sencha - Sales Team
- Join Date
- Mar 2007
- Location
- Melbourne, Australia (aka GMT+10)
- Posts
- 738
- Vote Rating
- 6
it would be renderTo: 'div' (with quotes) where 'div' is the id of the div
so if you had
then you would code:Code:<div id="myContainer"></div>
Code:http://docs.sencha.com/ext-js/4-1/#!/api/Ext.AbstractComponent-cfg-renderTo var div = document.createElement('div');Ext.create('Ext.Button', { text: 'Button', renderTo: 'myContainer'});
Check out SenchaWorld.com for articles, screencasts, conference videos and more.
Sencha Technical Training : Asia Pacific Region
Code Validation : JSLint | JSONLint | JSONPLint
-
1 Aug 2012 10:48 PM #5
Thanks dawesi! Maybe it's a good thing to update those things in the docs? So I would know that I could render it to an element ID etc.
Well, it's working now, thanks guys


Reply With Quote


