2012-12-12 66 views
0

我有一個dojo(1.8.1)DataGrid,我無法檢索DataGrid中的所有選定項目(網格中的大約171條記錄)。問題是返回到selectedItem的一些數據是空的。DataGrid返回null selectedItem

有趣的是,如果我一路滾動到DataGrid的底部,然後運行,雖然下面的代碼,我得到的所有records..This是奇怪..

var gridy = dijit.byId("grid"); 
var items = gridy.selection.getSelected(); 
if (items.length) { 
    dojo.forEach(items, function(selectedItem) { 
    if (selectedItem !== null) { 
    dojo.forEach(gridy.store.getAttributes(selectedItem), 
      function(attribute){ 
       var value = gridy.store.getValues(selectedItem, attribute); 
       alert('attribute: ' + attribute + ', value: ' + value); 
      }); 
    } 
    }); 
} 

所以,當所有項目在網格中被選中(171)我只有50項顯示爲選中,其餘爲selectedItem變量爲空。奇怪的問題,看起來像DataGrid中的錯誤?

Thx !!

回答

1

這可能是由於paging(請參見DataGrid-tutorial at "Paging and Virtual Scrolling")。 「一次只能提供一小部分數據」。因此,一個討厭的解決方法可能是在instanciating時將屬性的rowsPerPage-屬性設置爲高值(如1000)。它應該高於在網格中始終顯示的期望最大行數。

+0

謝謝!我永遠不會有300行左右的數據,所以這個解決方案很好。將rowsPerPage設置爲1000,我將所有選定的行都不滾動到底部。 – GoinOff

+0

很高興我可以幫助:)順便說一句:我猜即使滾動到最底部會肯定會得到你所有的東西,因爲他們說,它一次最多保留三頁。所以這取決於.. – nozzleman