Reputation: 5355
I have an ng-grid and it allows multiple selections.
After doing a save operation, I want to deselect the selected rows.
I tried doing something like this.selectedItems = [].
However, when I do that, if I select a row in ng-grid later, it doesnt bind to this.selectedItems. Instead it just remains an empty array.
My question here is on save, I want to be able deselect selected row.After that, any rows I select should bind to this.selectedItems.
Following is what I have for Grid options.
Any ideas and suggestions are greatly appreciated.
this.$scope.gridOptions = {
data: 'myData',
enablePaging: true,
showFooter: true,
totalServerItems: 'totalServerItems',
pagingOptions: this.$scope.pagingOptions,
sortInfo: this.$scope.sortOptions,
useExternalSorting: true,
selectedItems: this.selectedItems,
multiSelect: true
}
Upvotes: 4
Views: 7975
Reputation: 888
The following is working for me:
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: 3
Reputation: 1181
This works for me!!
for one item:
var index = row.rowIndex; //selected row index
vm.expenseDataGridOptions.selectItem( index , false)
Upvotes: 0
Reputation: 86
$scope.gridOptions.$gridScope.toggleSelectAll(false, false);
// note: false,falsethis.selectedItems.length =0
both of them work for me.
Upvotes: 1
Reputation: 2654
Instead of
this.selectedItems = []
do
this.selectedItems.length =0
Upvotes: 0
Reputation: 18055
i actually had faced the same issue and after looking at the code of ng-grid, i had arrived at below solution
$scope.gridOptions.$gridScope.toggleSelectAll(false, true);
i dont remember the details of the parameters now, sorry for that...
Upvotes: 1