开发者

GWT - Implement programmatic tab selection of a TabLayoutPanel and then scroll to a particular element contained in the tab?

开发者 https://www.devze.com 2023-02-19 08:18 出处:网络
I have a TabLayout panel with 2 tabs. I would like to programmatically select the 2nd tab and then scroll to a particular element within the tab. This is how my code looks like:

I have a TabLayout panel with 2 tabs. I would like to programmatically select the 2nd tab and then scroll to a particular element within the tab. This is how my code looks like:

public void scrollToTextArea(final String textArea)
{
    TabPanel.selectTab(1); //tab selection
    textArea.getElement().scrollIntoView(); //scroll to text area field
}

I tried using a deferred开发者_高级运维 command to run the scroll portion, but was still unable to get the right display.

Is there a specific way to implement this functionality?


This worked:

public void scrollToTextArea(final String textArea)
{
    TabPanel.selectTab(1); //tab selection
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand()
        {
            public void execute()
            {
                textArea.getElement().scrollIntoView();
            }
        });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消