Index.js
export class DialogEdit extends SampleBase {
constructor() {
super(...arguments);
this.toolbarOptions = ["Add", "Edit", "Delete"];
this.editSettings = {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: "Dialog"
};
this.editparams = {
params: { popupHeight: "300px", change: this.onChnage.bind(this) }
};
this.validationRules = { required: true };
this.orderidRules = { required: true, number: true };
this.pageSettings = { pageCount: 5 };
}
onChnage(args) {
this.gridInstance.editModule.editFormValidate(); // call the function to initiate the validation
}
render() {
return (
<div className="control-pane">
<div className="control-section">
<GridComponent
dataSource={data}
toolbar={this.toolbarOptions}
ref={grid => (this.gridInstance = grid)}
allowPaging={true}
editSettings={this.editSettings}
pageSettings={this.pageSettings}
>
<ColumnsDirective>
<ColumnDirective
field="OrderID"
headerText="Order ID"
width="120"
textAlign="Right"
validationRules={this.orderidRules}
isPrimaryKey={true}
/>
<ColumnDirective
field="CustomerName"
headerText="Customer Name"
width="150"
/>
<ColumnDirective
field="Freight"
headerText="Freight"
width="120"
format="C2"
textAlign="Right"
editType="numericedit"
/>
<ColumnDirective
field="OrderDate"
headerText="Order Date"
editType="datepickeredit"
format="yMd"
width="170"
/>
<ColumnDirective
field="ShipCountry"
validationRules={this.validationRules}
headerText="Ship Country"
width="150"
editType="dropdownedit"
edit={this.editparams}
/>
</ColumnsDirective>
<Inject services={[Page, Toolbar, Edit]} />
</GridComponent>
</div>
</div>
);
}
}
render(<DialogEdit />, document.getElementById("sample")); |