How to clear selections?
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?
Ok, I found two ways to do this.
$scope.gridOptions.selectAll(false);
or
$scope.gridOptions.selectedItems.length = 0;
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()
This looks resolved, closing.
Seems like it's
$scope.gridApi.selection.clearSelectedRows()