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

Stay in add mode after an error occurs.

Hi,

In my scenario
  • Click Add from the toolbar.
  • Enter all necessary data.
  • Press Update.
  • An error occurs because of some validation when sending data to server.
  • User receives a custom modal popup message.
  • User presses OK to close popup message.
At this point I would like the user to return to the Add mode row with previous values that they entered so they can make changes and not have to reenter the entire row of data again.

Hope this makes sense.

Peace.

1 Reply

HJ Hariharan J V Syncfusion Team June 18, 2019 02:03 AM

Hi John, 

Thanks for contacting Syncfusion support. 

We have analyzed your requirement and we suggest you to use the below way to achieve your requirement. You can bind actionBegin event and apply args.cancel as false to prevent the actions. Make AJAX request in actionBegin event and do your server side validation based on the AJAX success you may add the record programmatically by using addRecord method. 

Please refer the code example for more information. 

<ejs-grid #grid [dataSource]='data' [editSettings]='editSettings' [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' (actionBegin)="actionBegin($event)" 
    . . . . .  
</ejs-grid> 
 
 
actionBegin(args: any) { 
        if (args.action === 'add' && args.requestType === 'save') { 
            if(this.flag){ // If its from addRecord method then no need to cancel the action 
            args.cancel = true; 
            // make ajax request and do your server side validation 
            // in ajax success you can use the addRecord method (you can get edited data in args.data) to add the record in grid 
            } 
        } 
    } 

function Success(data) { 
        . . . . . 
        this.grid.editModule.addRecord(args.data);    //Add a record to Grid 
        this.flag = false; // default value true 
        popup.modal('hide'); 
 
    } 



Regards, 
Hariharan 


Loader.
Live Chat Icon For mobile
Up arrow icon