-
9 Nov 2011 3:05 PM #1
Answered: How to set an Ext.Button into an Ext.Panel with specific html layout
Answered: How to set an Ext.Button into an Ext.Panel with specific html layout
Hi,
I have an Ext.Panel that sets up its html property for a customer html layout.
How do I add an Ext.Button into this html, let's say into one specific div tag.
Example...
Thanks,Code:Ext.define('app.view.MyPanel', { extend: 'Ext.Panel', xtype: 'mypanel', alias: 'mypanel', config: { scrollable: true, html: '<div> lot's of html here...'+ '<div id="button">set button in here</div>'+ '</div>' } });
Frank
-
Best Answer Posted by mitchellsimoens
You would have to use renderTo on the Ext.Button to render it into a specific element after the Ext.Panel has been rendered.
-
10 Nov 2011 5:00 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
You would have to use renderTo on the Ext.Button to render it into a specific element after the Ext.Panel has been rendered.
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.
-
10 Nov 2011 8:46 AM #3
Thanks. Is there a method this can ideally be placed to? Something like this:
Thanks,Code:Ext.define('app.view.MyPanel', { extend: 'Ext.Panel', xtype: 'mypanel', alias: 'mypanel', config: { scrollable: true, html: '<div> lot's of html here...'+ '<div id="button">set button in here</div>'+ '</div>' }, afterRenderOrSomethingSimilar: function() { // ????? this.callParent(arguments); new Ext.Button({ renderTo: 'button', text: 'Click Me', }); } });
Frank
-
10 Nov 2011 2:18 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
That's the only way to accomplish what you want to do.
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.
-
10 Nov 2011 3:33 PM #5
Well, utilizing the panel's show event works fine -- although this code doesn't look too beautiful I have to admit.

Cheers,Code:Ext.define('app.view.MyPanel', { extend: 'Ext.Panel', xtype: 'mypanel', alias: 'mypanel', config: { scrollable: true, html: // usually defined in a separate template file '<div> lots of html here...'+ '<div id="button">set button in here</div>'+ '</div>' }, buttonsDone: false, show: function () { this.callParent(arguments); if(this.buttonsDone) return; this.buttonsDone = true; new Ext.Button({ renderTo:'button', text: 'Click Me' }); } });
Frank


Reply With Quote