问题
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