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')); |