1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    35
    Vote Rating
    0
    Alona Oz is on a distinguished road

      0  

    Default 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);
        }

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,714
    Vote Rating
    107
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    After modifying a container, you need to call layout on it.

  3. #3
    Ext User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    ikovaltaras is on a distinguished road

      0  

    Default


    @sven layout() and even layout(true) will not help, this is the same issue that I have posted about.

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,714
    Vote Rating
    107
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    Works fine for me. I just run it against latest SVN.

  5. #5
    Ext User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    ikovaltaras is on a distinguished road

      0  

    Default


    i not tried with svn version, i have 2.2.0

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,714
    Vote Rating
    107
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    This should run against 2.2.0 final too.

Similar Threads

  1. Dynamicly injecting elements into the head
    By ReSpawNnL in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 11 Jun 2010, 3:28 AM
  2. Adding and removing form elements
    By Northie in forum Ext 3.x: Help & Discussion
    Replies: 11
    Last Post: 7 Dec 2009, 6:35 AM
  3. Dynamicly Adding Tabs Question
    By netnutmike in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 17 Nov 2008, 9:55 AM
  4. Adding elements to a panel
    By swamyveera in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 22 Mar 2008, 3:08 AM
  5. Adding elements to PagingToolbar
    By josh in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 21 Jun 2007, 10:23 AM