如何禁止选择与beforeSelectionChange在NG-网格选择所有chekbox选择 [英] how to disallow selection with beforeSelectionChange for select All chekbox selection in ng-grid

查看:325
本文介绍了如何禁止选择与beforeSelectionChange在NG-网格选择所有chekbox选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该beforeSelectionChange是被称为与rowItem阵列的同时单击选择在标题中的所有复选框,没有选项来禁用选择。我有根据模型的一些行禁用的复选框的要求。我可以用CheckboxCellTemplate配置NG-禁用做到这一点。但我想对所有选择点击复选框时禁用行不能被选择。有没有办法做到这一点?

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?

感谢

推荐答案

得到这个固定以下解决方案,请让我知道,如果你有更好的解决办法,或者你看到任何问题与此有关。

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

这篇关于如何禁止选择与beforeSelectionChange在NG-网格选择所有chekbox选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆