Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    45
    Vote Rating
    0
    raivis is on a distinguished road

      0  

    Default BoxLayoutContainer adds all new widgets at position 0, not at the end

    BoxLayoutContainer adds all new widgets at position 0, not at the end


    HBoxLayoutContainer and VBoxLayoutContainer adds new widgets at position 0 (on top of each other), not at the end of the widget list, if widgets are added at runtime. Widgets get in place only after container gets resized.
    rev 1806

    First 5 ToggleButtons, that are being added in a constructor, are placed correctly, but when you click any of those buttons to add new at runtime, you will see that new buttons are being placed on top of the first button.

    Code:
    public class GxtModule implements EntryPoint, ClickHandler {    
        HBoxLayoutContainer hlc;
    
    
        @Override
        public void onModuleLoad() {
            RootPanel rootPanel = RootPanel.get();
            hlc = new HBoxLayoutContainer();
            rootPanel.add(hlc);
            for (int i = 0; i < 5; i++) {
                ToggleButton b = new ToggleButton("Button " + i);
                b.setLayoutData(new BoxLayoutData(new Margins(0, 5, 0, 0)));
                b.addDomHandler(this, ClickEvent.getType());
                hlc.add(b);
            }
        }
    
    
        @Override
        public void onClick(ClickEvent event) {
            ToggleButton b = new ToggleButton("Button " + hlc.getWidgetCount());
            b.setLayoutData(new BoxLayoutData(new Margins(0, 5, 0, 0)));
            b.addDomHandler(this, ClickEvent.getType());
            hlc.add(b);
        }
    }

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Try to call forceLayout after adding them.

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    45
    Vote Rating
    0
    raivis is on a distinguished road

      0  

    Default


    calling forceLayout() fixes that. Is it supposed to be like that or forceLayout() won't be needed in a final version?

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Posts
    54
    Vote Rating
    0
    DarekKay is on a distinguished road

      0  

    Default


    It's always have been like that (previously doLayout(boolean force)). Consider adding 100 widgets at runtime - it wouldn't make any sense to layout them after each component added.

  5. #5
    Sencha User
    Join Date
    Jul 2011
    Posts
    45
    Vote Rating
    0
    raivis is on a distinguished road

      0  

    Default


    Yes, I thought about it just few seconds after posting the question.

Thread Participants: 2