We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to perform asynchronous operation in actionBegin event in Angular Grid

Hi,

I have a requirement, when the current row input validation of the grid fails, not allowed to select other rows.

I add the check in the grid actionBegin, but the code "args.cancel=true;" doesnot work when I call the asynchronous check function. It works for Non-asynchronous check.
What should I do?



1 Reply 1 reply marked as answer

PG Praveenkumar Gajendiran Syncfusion Team October 16, 2020 01:56 PM UTC

Hi lorryl,

Greetings from Syncfusion support.

We checked your query and provided code. Based on that we would like to inform you that, by default in EJ2 Grid- actionBegin is the synchronous function, we cannot handle any asynchronous operation in the actionBegin event. So you cannot perform asynchronous operation in this event. 

If you want to perform an asynchronous operation, we suggest you use the args.cancel as “true” initially based on the flag value.

Once you have checked the args.cancel then you can perform an asynchronous operation. Once you got success in an asynchronous operation we suggest you to call the “endEdit()” method of Grid. If you call endEdit method, you will receive the args.requestType as “Save”, now you can check the flag value and then set the args.cancel as true.

Code Example :
 
function actionBegin(args: any): void { 
      var flag; 
        if (args.requestType === 'save') { 
           if(flag){ 
             args.cancel= true; 
             flag = false 
           } 
           // perform your asynchronous function here 
           //asynchronous function.onSuccess = function (result) { 
          //    flag= true; 
          //    this.grid.endEdit();   
          //  } 
        } 
    } 
 
Please get back to us if you need further assistance.

Regards,
Praveenkumar G 


Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon