Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Scrolltobottom in vertical layout

    Hello,

    I have a vertical layout with a window component inside it (100% height). In this window component I have a button to add another window component, when the second window is added the scroll appears and I want to scroll to the bottom of the vertical layout to see the second window.


    myButton.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
    //create the second window to add
    final SecondWindow win2 = new SecondWindow ();
    my_vLayout.addMember(win2);

    my_vLayout.scrollToBottom();
    //Nothing happens

    }
    });

    It seems because scrolls to the bottom of the layout before it draw itself

    If a change, my_vLayout.scrollToBottom(); to a function with a callback works, f.e.

    SC.confirm("Title", "Continue?", new BooleanCallback(){
    @Override
    public void execute(final Boolean aBoolean){
    my_vLayout.scrollToBottom();
    }
    });

    Any ideas, thanks

    #2
    In order to allow for multiple changes to the layout (such as multiple added members) without causing several redraws, the added member is not synchronously draw()n when you call addMember(), so it has not influenced the scrollable area when you try to call scrollToBottom().

    You can call reflowNow() on the Layout to force immediate drawing - then scrollToBottom() will work.

    Comment


      #3
      Solved!!!

      Thanks

      Comment


        #4
        Using a deferred command seems to work for me with smartgwt 3.1d-2012-09-19.
        Theoretically it should buy us that we don't force the inline reflowing, consequently possibly saving some unnecessary redraws, such as in the case when you add multiple members to a layout...:
        Code:
        final Scheduler scheduler = Scheduler.get ();
            scheduler.scheduleDeferred (new Scheduler.ScheduledCommand() {
              public void execute() {
                canvas.scrollToBottom ();
              }
            });

        Comment

        Working...
        X