cancel row deletion async

Hi,

In my grid, I have setup the row delete button and subscribed to actionBegin event.

I would like to test if the row could be deleted and cancel if it's not the case.

It's working correctly if my test is synchronous but I need to fecth related data in IndexDB, so my test is asynchronous.

How can I cancel asynchronously?

Regards,

Matt Richard  


3 Replies

AS Aruna Shree Natarajan Syncfusion Team November 22, 2023 04:38 AM UTC

Please update ASAP



PJ Philippe JARRIGE November 22, 2023 09:57 AM UTC

Hello,

What do you want that I update please?

Regards,

Matt



VS Vikram Sundararajan Syncfusion Team November 22, 2023 01:23 PM UTC

Hi Matthieu,


Based on your query want to set the cancel based on the asynchronously then we suggest the below solution in which we have canceled the delete action initially regardless the asynchronously result. So, when you get the result, you can reinitiate the delete action using the “deleteRecord” method. Please refer to the below code example and sample link for more information.


  [app.component.ts]

 

 actionBegin(args: any): void {

    if (args.requestType === 'delete') {

      if (this.deleteFlag) {

        args.cancel = true;

        var cancelDelete = args.data[0].OrderID % 2 == 0;

        if (!cancelDelete) {

          this.deleteFlag = false;

          this.grid.deleteRecord();

        }

      } else {

        this.deleteFlag = true;

      }

    }

  }

 


Sample: https://stackblitz.com/edit/angular-x6htrz-as6sct?file=src%2Fapp.component.ts


deleteRecord: https://ej2.syncfusion.com/documentation/api/grid/#deleterecord


Please get back us if you need further assistance.


Regards,

Vikram S


Loader.
Up arrow icon