Deselect all rows in ng grid

Please find an example ng grid in plunker

http://plnkr.co/edit/CncDWCktXTuBQdDVfuVv?p=preview

This will allow the user to select only one row, but there will always be one row selected. I want to deselect all rows.

+6
source share
4 answers

ng-grid has the keepLastSelected option.

Try:

keepLastSelected: false in gridOptions. This will switch the selection.

Example

 $scope.gridOptions = { data: 'myData', selectedItems: $scope.mySelections, multiSelect: false, keepLastSelected: false }; 
+9
source

The following works for me:

Plunker

First you need to save gridApi:

 $scope.gridOptions.onRegisterApi = function (gridApi) { $scope.gridApi = gridApi; }; 

Then you can use:

 $scope.unSelectAll = function(){ $scope.gridApi.selection.clearSelectedRows(); } 
+3
source

just:

 $scope.gridApi.selection.clearSelectedRows() 
0
source

To select ALL rows, we use:

$scope.GridOptions.api.selectAll()

Here $scope.GridOptions are your own grid data

And to deselect all rows, we use:

$scope.gridOptions.api.deselectAll();

Here (.api) is the file, and you get this file from the (ag-grid.js) file from the Internet Url: https://cdnjs.com/libraries/ag-grid

0
source

All Articles