|
var dropDownValues;
export class NormalEdit extends SampleBase {
constructor() {
super(...arguments);
}
async componentDidMount() {
let response = await fetch(
`https://ej2services.syncfusion.com/production/web-services/api/Employees`
).then(res => res.json());
dropDownValues=[];
response.forEach((col) => {
let dpObj = {};
dpObj["Emp_id"] = col.EmployeeID;
dpObj["Emp_name"] = col.FirstName;
dropDownValues.push(dpObj);
});
}
dpParams = {
create: () => {
this.elem = document.createElement("input");
return this.elem;
},
read: () => {
return this.dropDownListObj.value;
},
destroy: () => {
this.dropDownListObj.destroy();
},
write :()=>{
this.dropDownListObj = new DropDownList({
dataSource:dropDownValues,
fields: { text: "Emp_name", value: "Emp_name"},
});
this.dropDownListObj.appendTo(this.elem);
}
};
render() {
return (
<div>
<GridComponent
dataSource={orderDataSource.slice(0, 5)}
editSettings={this.editOptions}
toolbar={this.toolbarOptions}
>
<ColumnsDirective>
. . .
<ColumnDirective
field="ShipCountry"
headerText="Ship Country"
width="150"
edit={this.dpParams}
textAlign="Right"
/>
</ColumnsDirective>
<Inject services={[Edit, Toolbar]} />
</GridComponent>
</div>
);
}
}
render(<NormalEdit />, document.getElementById("sample")); |