Search results

Add custom indication to unsaved value

You can add custom indication to unsaved input value by using the actionSuccess event, when data not submitted to the server.

In this sample, the actionSuccess event configured and the URL property not included. Then submit button clicked, the current editor value saved into input and data sending to server action prevented due to the URL property not configured.

But actionSuccess event will trigger the handler function with null argument values. In handler function data property primaryKey value checked, whether it empty or not. If it is empty custom class, added in the e-value-wrapper element to customize its styles.

To send input value to local, set the URL property as empty.

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 {
            display: flex;
            justify-content: center;
            align-items: center;
            visibility: visible;
            height: 80px;
        }

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

        #customtextbox {
            width: 150px;
        }

        .content-title {
            font-weight: 500;
            margin-right: 20px;
            display: flex;
            align-items: center;
        }

        #customtextbox.e-inplaceeditor .e-editable-value-wrapper .e-editable-value.e-send-error { /* csslint allow: adjoining-classes */
            color: red;
        }
    </style>
</head>
<body>
    <div id='root'>
        <div id='loader'>Loading....</div>
    </div>
</body>
</html>
import { isNullOrUndefined as isNOU } from '@syncfusion/ej2-base';
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' };
    }
    actionSuccess(e) {
        const keyVal = 'PrimaryKey';
        const primeKey = e.data[keyVal];
        if (isNOU(primeKey) || primeKey === '') {
            (document.querySelector('.e-editable-value')).classList.add('e-send-error');
        }
    }
    render() {
        return (<div id='container'>
        <span className="content-title"> Enter your name: </span>
        <InPlaceEditorComponent id='customtextbox' mode='Inline' value='Andrew' model={this.model} actionSuccess={this.actionSuccess = this.actionSuccess.bind(this)}/>
     </div>);
    }
}
export default App;