Skip to content Skip to sidebar Skip to footer

How To Disallow Selection With BeforeSelectionChange For Select All Chekbox Selection In Ng-grid

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 disab

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

Post a Comment for "How To Disallow Selection With BeforeSelectionChange For Select All Chekbox Selection In Ng-grid"