javascript - AngularJs ui-grid onRowSelectionChanged 没有更新变量值,它始终具有默认值
问题描述
上次我检查时(两三个月前)它运行良好,它们是一个使用默认布尔值 false 调用的变量,如下所示。
$scope.IsRowSelected = false;
我应该提到调试器何时在第一次设置为 true 时运行。但它来删除功能然后值读取默认值。我不明白如何处理这个错误。
代码如下:
$scope.IsRowSelected = false;
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope, function (row) {
//$scope.selectedEmpID = row.entity.id;
debugger;
$scope.selectedEntity = row.entity;
$scope.Check = true;
$scope.IsRowSelected = true;
//in here it shows IsRowSelected as true
});
}
$scope.DeleteEntity = function () {
debugger;
//when this funtion excecute the IsRowSelected = false
if ($scope.IsRowSelected == true) {
var selectedRow = $scope.selectedEntity;
}
}
解决方案
取消选择行时调用gridApi.selection.on.rowSelectionChanged函数,将noUnselect属性设置为true,因此无法取消选择行。
$scope.gridApi.selection.getSelectedRows();
使用此代码从网格中获取选定的行。
推荐阅读
- php - 如何在不刷新页面的情况下更新多选内容?
- python-3.x - 如何限制排列的数量
- sql - 在 SQL 中用空格包装所有标点符号
- flutter - 每当我的手机屏幕保护程序启动时,我的 FLUTTER 视频应用都会关闭视频
- postgresql - 如何更新 Pgadmin4 docker 镜像?
- vb.net - 有没有办法使用 VB.Net 在 Outlook 邮件界面上显示日期时间
- amazon-web-services - 在 AWS EC2 实例上启用压缩
- spring - Hystrix 回退方法返回 null
- java - Android MediaPlayer 在一段时间后停止工作
- c# - 即使没有拿起枪,枪也会射击 Unity 3D