[英]Ui grid check if any row selected?
I have a ui-grid and a button, When i click on button it should first check if at-least one row is selected and show alert on if not. 我有一个ui-grid和一个按钮,当我单击按钮时,它应该首先检查是否至少选中了一行,如果没有,则显示警告。 I tried
我试过了
gridApi.selection.getSelectedRows()
but its returning nothing, and I am not able to put any if-else check. 但它什么也没返回,因此我无法进行任何if-else检查。 (i don't want to use noUnselect) Can anybody help..?
(我不想使用noUnselect)有人可以帮忙吗?
Try to place your code inside onRegisterApi: 尝试将您的代码放在onRegisterApi中:
$scope.gridOptions = {
[...]
onRegisterApi : function (gridApi) {
$scope.gridApi = gridApi;
$log.debug(gridApi.selection.getSelectedRows() );
$scope.gridApi.grid.modifyRows($scope.gridOptions.data);
$scope.gridApi.selection.selectRow($scope.gridOptions.data[0]);
$log.debug(gridApi.selection.getSelectedRows() );
}
};
console.log(gridApi.selection.getSelectedRows().length);
it gives no.of rows selected.. 它给出了选择的行数。
if(gridApi.selection.getSelectedRows().length ==0)
no row is selected... 没有选择任何行...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.