ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

How to clear selections?

Open summer-liu opened this issue 12 years ago • 4 comments

I'm using ngGrid in a modal. Each time when I open modal, I need to select some items and do some actions, but $scope.gridOptions.selectedItems keeps all the history of selections.

When I try to clear the selections with $scope.gridOptions.selectedItems = [ ], next time nothing can be selected. Is there a way to clear selections history each time I close the modal?

summer-liu avatar Nov 27 '14 07:11 summer-liu

Ok, I found two ways to do this.

$scope.gridOptions.selectAll(false);

or

$scope.gridOptions.selectedItems.length = 0;

summer-liu avatar Nov 28 '14 07:11 summer-liu

Good to know. If you upgrade to uiGrid, you'll get access to a number of nifty features through gridAPI. You'll need to add this to your gridOptions:

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

Then if you want to clear your rows, you can call $scope.grid1Api.clearSelectedRows()

nairys avatar Dec 02 '14 19:12 nairys

This looks resolved, closing.

PaulL1 avatar Dec 10 '14 06:12 PaulL1

Seems like it's

$scope.gridApi.selection.clearSelectedRows()

shakhal avatar Oct 23 '15 14:10 shakhal