结帐我的plunker:link
var app = angular.module('app', []);
// some stupid error won't let me paste the whole code, please check plunker
重现:
注意:滚动时,会再次取消选择其他行。
答案 0 :(得分:0)
我添加了这样的东西,它起作用了:
beforeSelectionChange: function() {
var grid = angular.element('.ngGrid');
grid.data('alreadySelectedItems', grid.scope().selectedItems);
return true;
},
afterSelectionChange: function (rowItem) {
if (rowItem.selected === true) {
} else if (rowItem.selected === false) {
} else if (rowItem.length > 0) {
var selectedIds = [],
grid = angular.element('.ngGrid'),
renderedRows = grid.scope().renderedRows,
alreadySelectedItems = grid.data('alreadySelectedItems') || [];
angular.forEach(rowItem, function (row) {
if (row.selected === true) {
selectedIds.push(row.entity.Id);
}
});
angular.forEach(renderedRows, function (row) {
if (selectedIds.indexOf(row.entity.Id) === -1 && alreadySelectedItems.indexOf(row.entity) === -1) {
row.selected = false;
}
});
grid.removeData('alreadySelectedItems');
}
}