rajmohan
rajmohan

Reputation: 1618

deselect all rows in ng grid

Please find the ng grid example in plunker

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

It will allow user to select only one row but there will be one selected row at all time. I want to deselect all rows.

Upvotes: 6

Views: 9789

Answers (4)

Nav
Nav

Reputation: 111

For Selecting ALL Rows We Use ::

$scope.GridOptions.api.selectAll()

Here $scope.GridOptions is your own grid data

And For Deselecting All Rows We use::

$scope.gridOptions.api.deselectAll();

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

Upvotes: 0

hoogw
hoogw

Reputation: 5525

simply :

$scope.gridApi.selection.clearSelectedRows()

Upvotes: 0

Nico
Nico

Reputation: 888

The following works for me:

Plunker

First you need store gridApi:

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

Then you can use:

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

Upvotes: 5

KrishnaDhungana
KrishnaDhungana

Reputation: 2684

ng-grid has keepLastSelected option.

Try:

keepLastSelected: false in gridOptions. This will toggle selection.

Example

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

Upvotes: 9

Related Questions