Modal

When i use the grid inbuilt Add modal, the record shows added in grid ( if i refresh it goes away) even though it failed to Add to DB

How to avoid adding to the grid when my API call failed

I tried cancelling in   args.canceltrue;
 actionComplete(args) {
    if ((args.requestType === 'beginEdit' || args.requestType === 'add')) {
      const dialog = args.dialog;

      // change the header of the dialog
      dialog.header = 'New Link'//'Edit User ' + args.rowData[FirstName]
    }
    if (args.requestType === 'save') {
      args.canceltrue;
    }
  }







1 Reply 1 reply marked as answer

BS Balaji Sekar Syncfusion Team May 10, 2021 05:50 AM UTC

Hi Vin, 
 
Greetings from the Syncfusion support. 
 
Based on your query, we suspect that you need to prevent save action while API call failed so, we suggest you use actionBegin event with save requestType instead of actionComplete event. When we save the edited/added value to Grid’s dataSource it will trigger actionBegin first and once saved that value then triggers the actionComplete event. 
 
                                                https://ej2.syncfusion.com/angular/documentation/api/grid/saveEventArgs/ 
 
Regards, 
Balaji Sekar 


Marked as answer
Loader.
Up arrow icon