-
24 Mar 2011 1:20 AM #1
Insert new item to a panel from 'outside'...
Insert new item to a panel from 'outside'...
Why does this not work?
I see the new Item in Firebug as second item in region 'east' (after 'center'), but it will not be rendered.Code:var cockpit = Ext.getCmp('cockpit'); // This is a Panel in a TabPanel var sidebar = Ext.create('Ext.panel.Panel',{ region: 'east', width: '200px', html: '<h1>TEST</h1>', collapsible: true }); cockpit.add(sidebar);
What am I doing wrong?
-
24 Mar 2011 3:31 AM #2
Hi Jehu,
if your panel "cockpit" is already rendered, you have to call cockpit.doLayout() after adding.
-
24 Mar 2011 3:51 AM #3
Thank you, but panel still does not appear.
Code:var cockpit = Ext.getCmp('cockpit'); // This is a Panel in a TabPanel var sidebar = Ext.create('Ext.panel.Panel',{ region: 'east', width: '200px', html: '<h1>TEST</h1>', collapsible: true }); cockpit.add(sidebar); cockpit.doLayout(); // so? Ext.getCmp('cockpit').doLayout(); // or so?
-
24 Mar 2011 3:58 AM #4
-
24 Mar 2011 4:33 AM #5
So sorry,
i've startet now with a blank new html with ExtJS4 pre5 and do this:
Sidebar won't come up.Code:var cockpit = Ext.create('Ext.panel.Panel',{ id:'cockpit', layout:'border', title:'TEST', renderTo:Ext.getBody(), width:'600px', height:'300px', items: [{ xtype: 'panel', id:'center', html: 'center', region: 'center' },{ xtype: 'panel', id:'south', html: 'south', region: 'south' }] }); var sidebar = Ext.create('Ext.panel.Panel',{ region: 'east', width: '200px', html: 'east', id:'sidebar', collapsible: true }); cockpit.add(sidebar); Ext.getCmp('center').doLayout(); Ext.getCmp('cockpit').doLayout(); Ext.getCmp('sidebar').doLayout();
-
24 Mar 2011 9:28 AM #6
You're right.
The problem is in the Ext.layout.container.Border. It initializes the regions only once on creation.
Another option is that you can add your sidebar as a docked item to your center region.Code:onLayout: function() { var me = this; if (!me.borderLayoutInitialized) { me.initializeBorderLayout(); //this method renders the regions and sets borderLayoutInitialized to true } ... }
greetings vollchraZCode:var sidebar = Ext.create("Ext.panel.Panel", { dock: 'right', ... }); Ext.getCmp('center').addDocked(sidebar);
-
25 Mar 2011 6:55 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
BorderLayout has never been able to add items after initialization. I'm not sure why it was designed this way but it has.
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.
-
26 Mar 2011 9:20 AM #8
Thank you all.
At the API Docs i've found the information too now (see "Notes")...
The hint there is to create a dummy panel inside and replace the content later. That's the way i go, because i need a collapsible panel, not a dock.
Similar Threads
-
How do you insert an item into a store?
By profunctional in forum Sencha Touch 1.x: DiscussionReplies: 3Last Post: 22 Oct 2010, 12:28 PM -
Insert item to Grid Store and let the row fade in
By grandfatha in forum Ext GWT: DiscussionReplies: 0Last Post: 9 Oct 2009, 4:54 AM -
How to insert an item(button) between...
By Joey Kwon in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 16 Jul 2009, 5:34 PM -
Insert item comboBox
By Perfect Lion in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 11 Oct 2007, 10:21 PM


Reply With Quote