DataGrid returning null selectedItem

偶尔善良 提交于 2019-12-08 13:32:59

问题


I have a dojo (1.8.1) DataGrid where I cannot retrieve all the selected items in the DataGrid (roughly 171 records in the grid). The problem is that some of data returned to selectedItem are null.

Interesting, If i scroll all the way to the bottom of the DataGrid and then run though the code below, I get all the records..This is weird..

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

So, when all items in the grid are selected (171) I only get 50 items showing as selected and the rest are null for selectedItem variable. Strange problem, seem like a bug in DataGrid??

Thx!!


回答1:


It could be due to paging (see DataGrid-tutorial at "Paging and Virtual Scrolling"). "only a small subset of the data is ever rendered at one time". Therefore, a nasty workaround could be to set the rowsPerPage-property of your DataGrid to a high value (like 1000) when instanciating it.. It should be higher then the expected maximum amount of rows to be displayd in the grid at all ever.



来源:https://stackoverflow.com/questions/13843339/datagrid-returning-null-selecteditem

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