admin管理员组文章数量:1305023
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
}
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
}
Share
Improve this question
asked Jul 25, 2014 at 15:49
SaiBandSaiBand
5,37517 gold badges58 silver badges79 bronze badges
6 Answers
Reset to default 3The following is working 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();
}
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...
$scope.gridOptions.$gridScope.toggleSelectAll(false, false);
// note: false,falsethis.selectedItems.length =0
both of them work for me.
Instead of
this.selectedItems = []
do
this.selectedItems.length =0
This works for me!!
for one item:
var index = row.rowIndex; //selected row index
vm.expenseDataGridOptions.selectItem( index , false)
Just use
$scope.gridOptions.selectAll(false);
This works for me.
本文标签: javascriptHow to deselect a row in angular js programatically in ng gridStack Overflow
版权声明:本文标题:javascript - How to deselect a row in angular js programatically in ng grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741792014a2397713.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论