我正在使用ui-grid来显示权限。 在单元格模板中显示复选框并执行更新..喜欢选中的复选框和所有复选框选择。现在我想在标题中添加复选框,单击后选择下面的所有复选框并取消全选。如果只有一个选定的"-"符号必须出现...这是我正在尝试的代码
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功能不起作用,无法更改复选框设计。
我错了。请帮忙
您可以使用:
$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);
}
}