ng-grid checkbox with filtering

Posted by WilliamLou on Stack Overflow See other posts from Stack Overflow or by WilliamLou
Published on 2014-08-22T04:16:36Z Indexed on 2014/08/22 4:20 UTC
Read the original article Hit count: 676

Filed under:
|
|

If I have a huge table with ng-grid, and I enabled a checkbox to select all. Is there a way for me to combine this selectAll feature with the filtering box. I mean when I filter out the rows, I want to click the checkbox so that the rows filtered will be all selected; once I clean out filter, those selectedRows are still left so that I can add more rows into it with other filters.

I created a Plunker code template here.

copy code here as well:

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

});

© Stack Overflow or respective owner

Related posts about angularjs

Related posts about filtering