2010-11-03 77 views
1

遵循GWT展示的示例和GWT中的示例,我實現了CellTable。 CellTable顯示前15個結果,但隨後的頁面僅顯示加載欄。試圖返回到前15個結果只顯示加載欄。引發JavaScript控制檯或GWT開發人員控制檯中的錯誤。GWT 2.1 CellTable僅顯示加載條

任何人都可以給予的幫助或見解將不勝感激。

此外,我試過以下,它也從發生同樣的事情遭遇:

List<String> stringsList = new ArrayList<String>(); 

    for(int i = 0; i < 60; i++){ 
     stringsList.add("" + i); 
    } 

    CellTable<String> cellTable = new CellTable(); 

    TextColumn<String> nameColumn = new TextColumn<String>(){ 
     @Override 
     public String getValue(String string){ 
      return string; 
     } 
    }; 

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); 
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); 
    pager.setDisplay(cellTable); 

    cellTable.addColumn(nameColumn, "App Name"); 
    cellTable.setRowCount(stringsList.size(), true); 
    cellTable.setRowData(0, stringsList); 
    RootLayoutPanel.get().add(cellTable); 
    RootLayoutPanel.get().add(pager); 

回答

1

這種情況發生時,有一些問題,setVisibleRange或類似的方法。當支持數據提供者的列表沒有足夠的值或其他東西時,我會得到很多。我建議你跟蹤你的程序到你要改變可見範圍的地方,並檢查所有進入你的方法的值。

+0

我編輯了我的初始文章以包含我試過的代碼片段,它產生了與我通過更復雜的實現看到的相同的結果。 – Eric 2010-11-03 14:23:22

5

爲什麼不使用DataProvider和setList來填充表?在某處,我讀到這是推薦的方法,setRowData不應該被使用(因爲它可能會導致一些奇怪的行爲)

+0

我去了並且實現了一個像你所建議的那樣的dataProvider,並且讓所有的東西都能正常工作。非常感激。 – Eric 2010-11-04 10:38:35

+0

然後選擇它作爲正確答案? – slugmandrew 2013-09-19 13:48:37

3

我認爲你需要一個數據提供者來將數據推入單元格表。添加下一個代碼,它應該工作。

ListDataProvider dataProvider = new ListDataProvider(); 
dataProvider.setList(stringsList); 
dataProvider.addDataDisplay(cellTable);