Tuesday, March 11, 2014

Re: GWT ScrollPanel not scrolling when hidden

It will work if I make the panel visible in a different moment/event chain?

On Tuesday, March 11, 2014 1:44:50 PM UTC+1, Winston Britto wrote:
You can use the below code

RootPanel.get().add(new Button("TEST", new ClickHandler() {

                        @Override
                      public void onClick(ClickEvent event) {
                        scrollPanel.scrollToTop();
                             scrollPanel.setVisible(false);
                         Scheduler.get().scheduleDeferred(
                                              new Scheduler.ScheduledCommand() {
                                                     @Override
                                                      public void execute() {
                                                        scrollPanel.scrollToBottom();
                                                  }
                                              });
                            scrollPanel.setVisible(true);
                  }
              }));



On Tuesday, March 11, 2014 4:37:50 PM UTC+5:30, Federico De Faveri wrote:
I have a ScrollPanel and I want to reset his scrolling position when it is hidden.
To do so I call the scrollTop method. As I can see it is not working only when the ScrollPanel is hidden.

Here a sample code:

 
public void onModuleLoad() {
   
StringBuilder html = new StringBuilder();
   for (int i = 0; i<1000; i++) html.append("row "+i+"<br>");

   HTMLPanel content = new HTMLPanel(html.toString());

   final ScrollPanel scrollPanel = new ScrollPanel(content);
   scrollPanel
.setHeight("200px");
   RootPanel.get().add(scrollPanel);

   RootPanel.get().add(new Button("TEST", new ClickHandler() {

   
@Override
   
public void onClick(ClickEvent event) {
      scrollPanel
.scrollToTop();
      scrollPanel
.setVisible(false);
      scrollPanel
.scrollToBottom();
      scrollPanel
.setVisible(true);
   
}
  }));
}



After clicking the TEST button the ScrollPanel keep is top position.
Any idea how to scroll it when hidden?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment