2011-03-24 31 views
2

我有一個帶有2個選項卡的TabLayout面板。我想以編程方式選擇第二個選項卡,然後滾動到選項卡中的特定元素。這是我的代碼看起來像:GWT - 實現TabLayoutPanel的編程選項卡選擇,然後滾動到選項卡中包含的特定元素?

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

我試圖用延期命令來運行渦管部,但仍無法得到正確的顯示。

是否有一種實現此功能的特定方法?

回答

3

這工作:

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