-
1 Nov 2010 4:13 AM #1
Adding elements dynamicly to LayoutContainer
Adding elements dynamicly to LayoutContainer
There is something that I probably don't understand. I try to create a vertical layout container and add elements to it on button click. But this doesn't work, the elements are not drawn. What is the problem?
Also when I try to add Label element instead of Button, it draws them in one horizontal line instead of putting them vertically.
Code:public class MYTest implements EntryPoint { public void onModuleLoad() { final LayoutContainer postsContainer = new LayoutContainer(); VBoxLayout layout = new VBoxLayout(); layout.setPadding(new Padding(5)); layout.setVBoxLayoutAlign(VBoxLayout.VBoxLayoutAlign.LEFT); postsContainer.setLayout(layout); Button b = new Button("add new element"); b.addListener(Events.OnClick,new Listener<ButtonEvent>() { public void handleEvent(ButtonEvent buttonEvent) { postsContainer.add(new Button("New Label")); } }); postsContainer.add(b); postsContainer.add(new Button("New Label"), new VBoxLayoutData(new Margins(0, 0, 5, 0))); postsContainer.add(new Button("New Label2"), new VBoxLayoutData(new Margins(0, 0, 5, 0))); Viewport viewport = new Viewport(); viewport.setLayout(new FitLayout()); viewport.add(postsContainer); RootPanel.get().add(viewport); }
-
1 Nov 2010 4:27 AM #2
After modifying a container, you need to call layout on it.
-
1 Nov 2010 7:32 AM #3
@sven layout() and even layout(true) will not help, this is the same issue that I have posted about.
-
1 Nov 2010 7:35 AM #4
Works fine for me. I just run it against latest SVN.
-
1 Nov 2010 7:38 AM #5
-
1 Nov 2010 7:39 AM #6
This should run against 2.2.0 final too.
Similar Threads
-
Dynamicly injecting elements into the head
By ReSpawNnL in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 11 Jun 2010, 3:28 AM -
Adding and removing form elements
By Northie in forum Ext 3.x: Help & DiscussionReplies: 11Last Post: 7 Dec 2009, 6:35 AM -
Dynamicly Adding Tabs Question
By netnutmike in forum Ext 2.x: Help & DiscussionReplies: 7Last Post: 17 Nov 2008, 9:55 AM -
Adding elements to a panel
By swamyveera in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 22 Mar 2008, 3:08 AM -
Adding elements to PagingToolbar
By josh in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 21 Jun 2007, 10:23 AM


Reply With Quote