AngularJs ui-grid onRowSelectionChanged is not updating variable value, always it has default value

it worked fine last time i check(two or three months ago) their is a variable called with the default boolean value false like below.

$scope.IsRowSelected = false;

And i should mention when the debugger runs on first time value set as true. But it come to delete function then the value reads the default value. i cant understand how to handle this error.

code is below :

 $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;
     }
}
    
    
 

728x90

1 Answers AngularJs ui-grid onRowSelectionChanged is not updating variable value, always it has default value

gridApi.selection.on.rowSelectionChanged function call when row is getting unselect, set noUnselect property to true,so row cant be unselected.

$scope.gridApi.selection.getSelectedRows();

use this code to get the selected row from the grid.

Working Fiddle

4 months ago