You can add this to the grid controller:
$scope.multiSelect = false; // control/shift/meta keydown enables multiselect $('.your-grid').keydown(function (e) { if ((e.keyCode === 16 || e.keyCode === 17 || e.metaKey || e.keyCode === 224 || e.keyCode === 91 || e.keyCode === 93) && !$scope.multiSelect) { $scope.multiSelect = true; } }); // keyup disables it $('.your-grid').keyup(function (e) { if (e.keyCode === 16 || e.keyCode === 17 || e.metaKey || e.keyCode === 224 || e.keyCode === 91 || e.keyCode === 93) { $scope.multiSelect = false; } }); $scope.gridOptions.beforeSelectionChange = function () { // if the shift/ctrl/meta keys aren't pressed, then each selection // will clear all the previous ones if (!$scope.multiSelect) { for (var i = 0; i < $scope.gridOptions.data.length; ++i) { $scope.gridOptions.selectRow(i, false); } } return true; };
If your view looks something like this:
<div class="your-grid" ng-grid="gridOptions">
The reason for all the different key code values ββis that the Mac command line key code is browser dependent. You can use e.metaKey, but this does not work at all (Mac Chrome, I do not believe it). Therefore, to be safe, you can check all of these KeyCode values ββthat are described in the SO message: How to capture a Mac command key using JavaScript?
This solution is inspired by: AngularJS Change the ng-grid attribute to select multiple rows in the down key and another SO record that I cannot find at the moment.
jCuga source share