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

三世轮回 提交于 2019-12-12 21:19:31

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/5425195/gwt-implement-programmatic-tab-selection-of-a-tablayoutpanel-and-then-scroll-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!