React Form - Editor Properties
To change the properties of an editor, bind the property that should be changed in the editorOptions object to a state property.
App.js
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { Form, SimpleItem } from 'devextreme-react/form';
- import { CheckBox } from 'devextreme-react/check-box';
- const employee = {
- firstName: 'John',
- lastName: 'Heart',
- phone: '+1(213) 555-9392',
- email: 'jheart@dx-email.com'
- };
- class App extends React.Component {
- constructor() {
- super();
- this.state = {
- editorOptions: {
- disabled: false
- }
- };
- this.onCheckBoxValueChanged = this.onCheckBoxValueChanged.bind(this);
- };
- render() {
- return (
- <div>
- <Form formData={employee}>
- <SimpleItem dataField="firstName" editorOptions={this.state.editorOptions} />
- <SimpleItem dataField="lastName" />
- <SimpleItem dataField="phone" />
- <SimpleItem dataField="email" />
- </Form>
- <CheckBox
- text="Show the Phone Number"
- value={this.state.editorOptions.disabled}
- onValueChanged={this.onCheckBoxValueChanged} />
- </div>
- );
- }
- onCheckBoxValueChanged(e) {
- this.setState({
- editorOptions: {
- disabled: e.value
- }
- });
- }
- }
- export default App;
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.