"The cell editor for a particular column can be specified using a React Component. The column.editTemplate
property used to define the corresponding column editor."
after that when you go to the link column.editTemplate
points you see :
"Defines the cell edit template that used as editor for a particular column. It accepts either template string or HTML element ID."
And the example says :
export default class App extends React.Component<{}, {}> { public editOptions: EditSettingsModel = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal' }; public toolbarOptions: ToolbarItems[] = ['Add', 'Edit', 'Delete', 'Update', 'Cancel']; public editTemplate(args: object) { return (<DatePickerComponent value={getValue('OrderDate', args)} id="OrderDate" placeholder="Order Date" floatLabelType='Never'/>) } public render() { return <GridComponent dataSource={data} editSettings={this.editOptions} toolbar={this.toolbarOptions} height={265}> <ColumnsDirective> <ColumnDirective field='OrderID' headerText='Order ID' width='100' textAlign="Right" isPrimaryKey={true}/> <ColumnDirective field='CustomerID' headerText='Customer ID' width='120'/>
{this.editTemplate}/> ColumnsDirective> <Inject services={[Edit, Toolbar]} /> GridComponent> } };
My problems :
I can not run a sample that you have presented there. And I got bad runtime errors sometimes random errors !!
As you said in the documentation is it possible to return any React component in the editTemplate function?
In your example you've return a datetime picker .I want to return a dropdown component.
Is there and limitation in the component and the returning component should obey particular rules?
and would you please provide me a js sample project (not tsx) that implementing this feature?
Thanks
export class NormalEdit extends SampleBase {
editTemplate(args) {
return (<DropDownListComponent dataSource={orderDataSource} value={getValue('ShipCountry', args)} fields={this.fields} id="ShipCountry" placeholder="ShipCountry" floatLabelType='Never'/>)
}
render() {
return (
<div>
<GridComponent dataSource={orderDataSource} editSettings={this.editOptions} toolbar={this.toolbarOptions} height={265}>
<ColumnsDirective>
<ColumnDirective field='OrderID' headerText='Order ID' width='100' textAlign="Right" isPrimaryKey={true}/>
<ColumnDirective field='ShipCountry' headerText='Ship Country' width='150' editTemplate={this.editTemplate.bind(this)}/>
. . .
</ColumnsDirective>
<Inject services={[Edit, Toolbar]} />
</GridComponent>
</div>);
}
}
render(<NormalEdit />, document.getElementById('sample'));
|
Thanks for your answer
I updated my syncfusion packages and it worked
but now my grid does not show data :(((
Im using RemoteSaveAdaptor and setting my data in json property. What is changed that the grid does not list data in json? Does json format have changed?
Thats really annoying !