Search results

Buttons

The In-place Editor has an action for save and cancel using buttons. The saveButton and cancelButton properties accepts the ButtonModel objects for customizing the save and cancel button properties.

Buttons can be show or hide by setting a boolean value to the showButtons property.

Without buttons value actions will be performed by the following way.

  • actionOnBlur: By clicking out-side of the editor component it will get focus out and perform action based on this property value.
  • submitOnEnter: Pressing Enter key it performs the submit action, when this property set to true.

In the following sample, the content and cssClass properties of Button value assigned to the saveButton and cancelButton properties to customize its appearance. Also check or uncheck a checkbox buttons render or removed from the editor.

To restrict either save or cancel button rendering into a DOM, simply pass empty object {} in the saveButton or cancelButton properties.

For more details about buttons, refer this documentation section.

Source
Preview
index.tsx
index.html
App.css.jsx
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App  from './App';

ReactDOM.render(<App />, document.getElementById('root'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 React In-place Editor Sample</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="//cdn.syncfusion.com/ej2/material.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
     <style>
        #container {
            visibility: visible;
        }

        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }

        .table-section {
            margin: 0 auto;
        }

        tr td:first-child {
            text-align: right;
            padding-right: 20px;
        }

        .sample-td {
            padding-top: 10px;
            min-width: 230px;
            height: 100px;
        }
    </style>
</head>
<body>
    <div id='root'>
        <div id='loader'>Loading....</div>
    </div>
</body>
</html>
import { CheckBoxComponent } from '@syncfusion/ej2-react-buttons';
import { InPlaceEditorComponent } from '@syncfusion/ej2-react-inplace-editor';
import * as React from "react";
import './App.css';
class App extends React.Component {
    constructor() {
        super(...arguments);
        this.model = { placeholder: 'Enter some text' };
        this.saveButton = { content: 'Ok', cssClass: 'e-outline' };
        this.cancelButton = { content: 'Cancel', cssClass: 'e-outline' };
    }
    onChange(e) {
        this.inplaceEditorObj.showButtons = e.checked;
        this.inplaceEditorObj.dataBind();
    }
    render() {
        return (<div id='container'>
         <table className="table-section">
         <tbody>
             <tr>
                <td> ShowButtons: </td>
                <td>
                    <CheckBoxComponent id='enableBtn' checked={true} label='Show' change={this.onChange = this.onChange.bind(this)}/>
                </td>
             </tr>
             <tr>
                 <td className="sample-td"> Enter your name: </td>
                 <td className="sample-td">
                    <InPlaceEditorComponent ref={(text) => { this.inplaceEditorObj = text; }} id='element' mode='Inline' value='Andrew' model={this.model} saveButton={this.saveButton} cancelButton={this.cancelButton}/>
                 </td>
              </tr>
            </tbody>
           </table>
     </div>);
    }
}
;
export default App;

See Also