-
Notifications
You must be signed in to change notification settings - Fork 490
How can i make select row and selectall using with checkbox? #163
Comments
I suppose you meant selecting rows not columns. |
is the sample still working ??? |
Use this example instead. |
Hi @l-lin, I don't know if the following is an issue or is the behavior by design. In your online sample I filter rows with a cell value starting by 8, then I check the checkbox on the header expecting only the rows matching the filter criteria will be checked but in your controller all properties are checked. See the following image for more info value 590 should be false, right??? |
Nope, indeed, this example is not complete 😞 There are still some tweaks to make it work. |
Mmmh...in fact, it all depends on the functionality you seek. If you really need to only check what you filter, you will need to use the search event and search the |
It's quite a useful feature only to be able to select all visible rows. I thought I wanted to share how I currently do it. Although it's not a complete code it will hopefully be useful to someone struggling with this. $scope.toggleAll = function () {
$scope.selectAll = !$scope.selectAll;
$scope.cbox.items = {}; //cbox.items contains all checked checkboxes
if ($scope.selectAll) { //If true then select visible
var oTable = $scope.dtInstance.dataTable;
var anNodes = $("#dt tbody tr");
for (var i = 0; i < anNodes.length; ++i) {
var rowData = oTable.fnGetData(anNodes[i]);
$scope.cbox.items[rowData.Guid] = true;
}
}
} |
I also noticed that headerCallback didn't work for me. I learned that it had to be called exactly two times for it to work. If to call $compile only once then ng-click would not work in the header, if call $compile more than twice then ng-click would be called x-number of times. .withOption('headerCallback', function (header) {
if (!$scope.dtOpts.counter)
$scope.dtOpts.counter = 1;
else
$scope.dtOpts.counter = $scope.dtOpts.counter + 1;
if ($scope.dtOpts.counter <= 2)
$compile(angular.element(header).contents())($scope);
}) |
Hi Guys, I have used @bluee's code above to change the toggle all function to make sure only the visible rows are selected when we check the selectAll checkbox. My function is as follows:
Thanks @bluee for your contribution, I was struggling a lot with this issue and finally found your post and modified it for my use. |
@bluee and @anishkvirani than you so much for this piece of code. I've been struggling with this for ages. Update Thanks to this I just found this So, in bootstrap datatables, all it needs to be done is simply:
That would solve all my problems. |
OK, I managed to do it. The selector-modifier can be used in angular-datatables the following way:
In my case specifically, I wanted to compare the value of the first collumn (the user ID) with my scope user variable's ID, and then select it, so this is the piece of code:
I don't know whether this is the best way to do it (probably not), but it worked for me and it might help someone in the same situation. |
Hello, can we achieve this "select row" in angular way |
Hi, @srkdk, my way was implemented on angular! |
Hi, @eliseguimaraes i want to select all checkboxes across all pages in angular datatable, any suggestions on how i can do it. |
@l-lin, is there any Angular 4 example of this? |
Not yet. |
Hi! I want to create selectall column using with checkbox. But i'm not handle selectrow data. How can i do?
The text was updated successfully, but these errors were encountered: