I use angularjs and DTOptionsBuilder to show grid table. I create a Select All check box for the first column (this column show a check box at each row.) + This is HTML source code:
<table dt-column-defs="dtColumnDefs" datatable="ng" dt-options="dtOptions" class="table table-bordered table-hover table-res" id="dataTables-res">
<thead>
<tr >
<th style="width: 15px;">
<input type="checkbox" ng-click="checkAllRes()" ng-model="selectedAllRes['checked']" >
<th >
...
<th >
<th translate="TABLE_RE.COMMENTS">Comments</th>
</tr>
</thead>
-
Source code in control:
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('order', [1 ,"desc"]).withOption('processing', true).withPaginationType('full_numbers');
$scope.checkAllRes = function() { var selectObject = {}; if ($scope.selectedAllRes['checked']) { angular.forEach($scope.res, function (item) { selectObject[item.resId] = true }); } $scope.selectedRes = selectObject ; };
My problem is: When I click Select All check box, all row on all pages are checked. I want:
Only rows on current page are checked. And, when I click on other page, Select All check box become unchecked. - When I click old page that I checked Select All check box before, I see all row on this page are checked and Select All check box is checked. (To sum up, I like it work the same as on Google Mail pages.)
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire