带过滤的ng-grid复选框

时间:2014-08-22 04:16:37

标签: angularjs filtering ng-grid

如果我有一个包含ng-grid的巨大表格,我启用了一个复选框来选择全部。有没有办法让我将这个selectAll功能与过滤框结合起来。我的意思是当我过滤掉行时,我想点击复选框,这样过滤的行将全部被选中;一旦我清理了过滤器,那些选定的行仍然会被留下,以便我可以使用其他过滤器添加更多行。

我创建了一个Plunker代码模板here

在这里复制代码:

 // main.js
 var app = angular.module('myApp', ['ngGrid']);
 app.controller('MyCtrl', function($scope) {
 $scope.mySelections = [];
 $scope.myData = [{name: "Moroni", age: 50},
                 {name: "Tiancum", age: 43},
                 {name: "Jacob", age: 27},
                 {name: "Nephi", age: 29},
                 {name: "Enos", age: 34},
                 {name: "Moroni", age: 50},
                 {name: "Tiancum", age: 43},
                 {name: "Jacob", age: 27},
                 {name: "Nephi", age: 29},
                 {name: "Enos", age: 34},
                 {name: "Moroni", age: 50},
                 {name: "Tiancum", age: 43},
                 {name: "Jacob", age: 27},
                 {name: "Nephi", age: 29},
                 {name: "Enos", age: 34},
                 {name: "Moroni", age: 50},
                 {name: "Tiancum", age: 43},
                 {name: "Jacob", age: 27},
                 {name: "Nephi", age: 29},
                 {name: "Enos", age: 34},];

$scope.filterOptions = {
    filterText: ''
};
$scope.gridOptions = { 
  data: 'myData',
  checkboxHeaderTemplate: '<input class="ngSelectionHeader" type="checkbox" ng-model="allSelected" ng-change="toggleSelectAll(allSelected)"/>',
  showSelectionCheckbox: true,
  selectWithCheckboxOnly: false,
  selectedItems: $scope.mySelections,
  multiSelect: true,
  filterOptions: $scope.filterOptions
};

});

0 个答案:

没有答案