如何在ui-grid angularjs中的标题中添加复选框

问题描述 投票:0回答:1

我正在使用ui-grid来显示权限。在cellTemplate显示复选框和执行更新...类似选中的复选框和所有复选框选择。现在我想在标题中添加复选框,一旦点击选中以下全部复选框并取消选择全部。如果只有一个选中的' - '符号必须出现..这是我正在尝试的代码

 angular.forEach($scope.moduleRoles, function (role, key) {
                $scope.mgridOptions.columnDefs.push({name: role, displayName: role, width: 150,headerCellTemplate: "<span> \
        <span  ng-class=\"'colt' + col.index\" class=\"ngHeaderText\"> \
            {{col.displayName}} \
            '<input type=\"checkbox\" ng-model=\"role.checked\" class=\"chckBox\" ng-click=\"checkAll(role.checked);\">' \
        </span> \
    </span>" , cellTemplate: '<input type="checkbox" ng-model="row.entity.roles[\'' + key + '\'].selected" ng-click="grid.appScope.updateModulePerms(row.entity,\'' + key + '\')">'});
            });

$ scope.moduleRoles包含来自服务器的角色数据。我能够在标题中添加复选框..但是checkAll功能不起作用,无法更改复选框设计。

哪里我错了。请帮忙

angularjs checkbox angular-ui-grid
1个回答
0
投票

您可以使用:

$scope.optionsGrid = {
    enableSelectAll: true,
    enableRowHeaderSelection: true
}

然后为行选择事件添加一个回调函数处理程序:

$scope.gridOptions.onRegisterApi = function (gridApi) {
                $scope.gridApi = gridApi;
                gridApi.selection.on.rowSelectionChanged($scope, callbackFunction);
                gridApi.selection.on.rowSelectionChangedBatch($scope, callbackFunction);
            }
 }
© www.soinside.com 2019 - 2024. All rights reserved.