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

Grid Add Issue

Thread ID:

Created:

Updated:

Platform:

Replies:

145205 Jun 12,2019 11:06 AM UTC Jun 13,2019 06:07 AM UTC React - EJ 2 1
loading
Tags: Grid
License Admin
Asked On June 12, 2019 11:06 AM UTC

Hi,

I am validating something from backend so in response i am getting error then too in that grid it is displaying that newly added line so how i can avoid it that if error is coming then it should not show that grid line in grid?

Pavithra Subramaniyam [Syncfusion]
Replied On June 13, 2019 06:07 AM UTC

Hi Sandeep, 
 
Thanks for contacting Syncfusion support. 
 
You can skip the add action based on validation result by setting the cancel as true in the actionComplete event. Please refer to the below code example, documentation link and sample link for more information. 
 
[index.jsx] 
export class NormalEdit extends SampleBase { 
    
    actionBegin(args) { 
         // works for add action. if you wan tto validate on both edit and add, remove the condition for args.action 
        if (args.requestType === 'save' && args.action == "add" ) { 
          if(args.data.OrderID == 1){  // here you do server validation and based on that enable "cancel"  
            args.cancel = true; 
          // if you want to stay in edit state you can remove the below line 
            this.gridInstance.closeEdit(); 
          } 
        } 
    } 
    render() { 
        return (<div className='control-pane'> 
          <GridComponent dataSource={orderDataSource} ref={grid => this.gridInstance = grid} toolbar={this.toolbarOptions} allowPaging={true}  
                                           editSettings={this.editSettings} pageSettings={this.pageSettings} actionBegin={this.actionBegin.bind(this)}> 
              <ColumnsDirective> 
                .  .  . 
              </ColumnsDirective> 
              <Inject services={[Page, Toolbar, Edit]}/> 
            </GridComponent> 
        </div>); 
    } 
} 
 
render(<NormalEdit />, document.getElementById('sample')); 
 
                            https://ej2.syncfusion.com/react/documentation/api/grid/#closeedit 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


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