1

I am using ng-grid of AngularUI-Grid, and having a checkbox for row selection. It gives me a checkbox in header too.

If user selects checkbox in header, I want some event/method to trigger in $scope, is there any way? I thought by specifying :- checkboxHeaderTemplate , I would get toggleSelectAll() method would get called. but it is not happening. Any clue? Also is there any Event or method of $scope which can get called on multiple row selection or un-selection.

 $scope.gridOptions = {
              data: 'dataList',
              enablePaging: true,
              showFooter: true,
              showFilter: true,
              totalServerItems: 'totalVehicles',
              pagingOptions: $scope.VehpagingOptions,
              filterOptions: $scope.VehfilterOptions.filterText,
              showSelectionCheckbox: true,
              beforeSelectionChange: $scope.beforeVehicleSelectionChange,
              checkboxHeaderTemplate: '<input class="ngSelectionHeader" type="checkbox" ng-show="multiSelect" ng-model="allSelected" ng-change="toggleSelectAll(allSelected, true)"/>'
          };

1 Answer 1

5

I found that ng-grid sends array of item to afterSelectionChange if multiple rows are being selected. I used this instead (this solved my problem):-

 $scope.afterVehicleSelectionChange = function (rowItem, event) {
            if (rowItem.length) {
                _.each(rowItem, function (item) {
                    updateItemOnSelectionChange(item);
                });
            } else {
                updateItemOnSelectionChange(rowItem);
            }
            return true;
        };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.