我有一个 ng-grid,它允许多项选择。
保存操作后,我想取消选中的行。
我尝试做类似 this.selectedItems = [] 的事情。
但是,当我这样做时,如果我稍后在 ng-grid 中选择一行,它不会绑定(bind)到 this.selectedItems。 相反,它只是一个空数组。
我的问题是保存,我希望能够取消选择选定的行。之后,我选择的任何行都应该绑定(bind)到 this.selectedItems。
以下是我的网格选项。
非常感谢任何想法和建议。
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
}
最佳答案
以下对我有用:
首先你需要store gridApi:
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
};
然后你可以使用:
$scope.unSelectAll = function(){
$scope.gridApi.selection.clearSelectedRows();
}
关于javascript - 如何在ng grid中以编程方式取消选择angularjs中的一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24959659/