【问题标题】:GWT - Implement programmatic tab selection of a TabLayoutPanel and then scroll to a particular element contained in the tab?GWT - 实现 TabLayoutPanel 的编程选项卡选择,然后滚动到选项卡中包含的特定元素?
【发布时间】:2011-03-24 20:36:15
【问题描述】:

我有一个带有 2 个选项卡的 TabLayout 面板。我想以编程方式选择第二个选项卡,然后滚动到选项卡中的特定元素。这就是我的代码的样子:

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

我尝试使用延迟命令来运行滚动部分,但仍然无法获得正确的显示。

有没有具体的方法来实现这个功能?

【问题讨论】:

    标签: gwt deferred-execution gwt-tablayoutpanel


    【解决方案1】:

    这行得通:

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

    【讨论】:

      猜你喜欢
      • 2011-07-04
      • 2015-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      • 1970-01-01
      相关资源
      最近更新 更多