Search code examples
angularjsangular-ui-gridsweetalert

UI grid check box selection change in a call back function


To check/uncheck the check box value, when the sweet alert cancel event is selected.

here in the call back function, not able to reset the check box value.

$scope.updateRow = function(row) {
  SweetAlertService.confirm('Are you sure?','', function(isConfirmed) {
    if (isConfirmed) {

    }else{
          if(row.entity.employed == "Y"){
         row.entity.employed = "N";
       }else if(row.entity.employed == "N"){
         row.entity.employed = "Y";
    }
     });

Code here . http://plnkr.co/edit/Sd7Uk5yTkhPFnzrsDknp?p=preview


Solution

  • The changes needed to run this are as follows:

    1. In SweetAlert.js set the timer to some bigger value. Current is 1500, set to timer: 150000.
    2. Include onRegisterApi in grid definition and after resetting the value of checkbox on click of cancel just refresh the grid using $scope.gridApi.core.refresh()

    Updated Plunker code: Here

    Hope this helps!