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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Stay in add mode after an error occurs.

Thread ID:

Created:

Updated:

Platform:

Replies:

145255 Jun 13,2019 08:29 PM UTC Jun 18,2019 10:03 AM UTC Angular - EJ 2 1
loading
Tags: Grid
John DOBSON
Asked On June 13, 2019 08:29 PM UTC

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.

Hariharan J V [Syncfusion]
Replied On June 18, 2019 10:03 AM UTC

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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon