问题
The beforeSelectionChange is being called with an rowItem array while clicking the select All checkbox in the header, no option to disallow selection. I have a requirement to disabled the checkbox for some row depending upon model. I can do it with CheckboxCellTemplate with configuring ng-disabled. But i want the disabled row not be selected when clicking on select all checkbox. Is there a way to do it?
Thanks
回答1:
Got this one fixed with the below solution, please let me know if you have a better solution or you see any issue with this.
$scope.myGridOptions = {
data: 'gridData',
enableSorting: false,
showSelectionCheckbox: true,
selectedItems: $scope.selectedData,
selectWithCheckboxOnly: true,
afterSelectionChange: function (rowItem) { return $scope.updateRowSelection(rowItem); }};
$scope.updateRowSelection = function (rowItem) {
if (rowItem.length) {
for(var i = 0 ; i < rowItem.length ; i ++ ) { //Foreach can be used
if (!$scope.isMySelectionAllowed(rowItem[i].entity)){
if (rowItem[i].selected) {
$scope.myGridOptions.selectRow(rowItem[i].rowIndex, false);
}
}
}
}
};
来源:https://stackoverflow.com/questions/21610945/how-to-disallow-selection-with-beforeselectionchange-for-select-all-chekbox-sele