Configuration in EJ2 TypeScript In place editor control

19 Apr 202322 minutes to read

Rendering modes

This section explains the supported rendering modes of the In-place Editor. Possible Rendering modes are as follows.

* Popup
* Inline

By default, Popup mode will be rendered, when opening an editor.

  • For Popup mode, editable container displays as like tooltip or popover above the element.

  • For Inline mode, editable container displays as instead of the element. To render Inline mode while opening the editor, specify mode as Inline.

In the following sample, the In-place Editor renders with Inline mode. You can dynamically switch into another mode by changing the drop-down item value.

import { InPlaceEditor, RenderMode } from '@syncfusion/ej2-inplace-editor';
import { DropDownList, ChangeEventArgs } from '@syncfusion/ej2-dropdowns';

let modeData: string[] = ['Inline', 'Popup'];

let modeObj: DropDownList = new DropDownList({
    dataSource: modeData,
    width: 'auto',
    change: onChange,
    value: 'Inline',
    placeholder: 'Select Mode'
});
modeObj.appendTo('#dropDown');

let editObj: InPlaceEditor = new InPlaceEditor({
    mode: 'Inline',
    value: 'Andrew',
    model: {
        placeholder: 'Enter some text'
    }
});
editObj.appendTo('#element');

function onChange(e: ChangeEventArgs): void {
    let mode: RenderMode = e.itemData.value as RenderMode;
    /* Switch into another mode */
    editObj.mode = mode;
    editObj.dataBind();
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 In-place Editor</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript In-place Editor Control" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <table class="table-section">
            <tr>
                <td> Mode: </td>
                <td>
                    <div id="dropDown"></div>
                </td>
            </tr>
            <tr>
                <td class="sample-td"> Enter your name: </td>
                <td class="sample-td">
                    <div id="element"></div>
                </td>
            </tr>
        </table>
    </div>
</body>

</html>

Pop-up customization

In-place Editor popup mode can be customized by using the title and model properties in popupSettings API.

Popup mode rendered by using the Essential JS 2 Tooltip control, so you can use tooltip properties and events to customize the behavior of popup via the model property of popupSettings API.

For more details, refer the tooltip documentation section.

In the following sample, popup title and position customized using the popupSettings property. All possible tooltip position data configured in the drop-down, if we change drop down item, selected value bound to model property and applied it to Tooltip control. Tooltip have following position options.

  • TopLeft
  • TopCenter
  • TopRight
  • BottomLeft
  • BottomCenter
  • BottomRight
  • LeftTop
  • LeftCenter
  • LeftBottom
  • RightTop
  • RightCenter
  • RightBottom
import { InPlaceEditor } from '@syncfusion/ej2-inplace-editor';
import { DropDownList, ChangeEventArgs } from '@syncfusion/ej2-dropdowns';

let positionData: string[] = ['TopLeft', 'TopCenter', 'TopRight', 'BottomLeft', 'BottomCenter', 'BottomRight', 'LeftTop', 'LeftCenter', 'LeftBottom', 'RightTop', 'RightCenter', 'RightBottom'];

let dropDownObj: DropDownList = new DropDownList({
    value: 'BottomCenter',
    dataSource: positionData,
    placeholder: 'Select a position',
    popupHeight: '150px',
    change: function(e: ChangeEventArgs): void {
        editObj.popupSettings.model.position = e.value;
        editObj.dataBind();
    }
});
dropDownObj.appendTo('#dropDown');

let editObj: InPlaceEditor = new InPlaceEditor({
    mode: 'Popup',
    value: 'Andrew',
    model: {
        placeholder: 'Enter some text'
    },
    popupSettings: {
        title: 'Enter name',
        model: {
            position: 'BottomCenter'
        }
    }
});
editObj.appendTo('#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 In-place Editor</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript In-place Editor Control" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <table class="table-section">
            <tr>
                <td> Position: </td>
                <td>
                    <div id="dropDown"></div>
                </td>
            </tr>
            <tr>
                <td  class="edit-heading sample-td"> Enter your name: </td>
                <td  class="sample-td">
                    <div id="element"></div>
                </td>
            </tr>
        </table>
    </div>
</body>

</html>

Event actions for editing

The event action of the editor that enable in the edit mode based on the editableOn property, by default Click is assigned, the following options are also supported.

  • Click: The editor will be opened as single click actions.
  • DblClick: The editor will be opened as double-click actions and it is not applicable for edit icon.
  • EditIconClick: Disables the editing of event action of input and allows user to edit only through edit icon.

In-place Editor get focus by pressing the tab key from previous focusable DOM element and then by pressing enter key, the editor will be opened.

In the following sample, when switching drop-down item, the selected value assigned to the editableOn property. If you changed to DblClick, the editor will open when making a double click on the input.

import { InPlaceEditor, EditableType } from '@syncfusion/ej2-inplace-editor';
import { DropDownList, ChangeEventArgs } from '@syncfusion/ej2-dropdowns';

let editableOnData: string[] = ['Click', 'DblClick', 'EditIconClick'];

let dropDownObj: DropDownList = new DropDownList({
    dataSource: editableOnData,
    width: 'auto',
    value: 'Click',
    change: onChange,
    placeholder: 'Select edit type'
});
dropDownObj.appendTo('#dropDown');

let editObj: InPlaceEditor = new InPlaceEditor({
    mode: 'Inline',
    value: 'Andrew',
    model: {
        placeholder: 'Enter some text'
    }
});
editObj.appendTo('#element');

function onChange(e: ChangeEventArgs): void {
    let editType: EditableType = e.itemData.value as EditableType;
    editObj.editableOn = editType;
    editObj.dataBind();
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 In-place Editor</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript In-place Editor Control" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <table class="table-section">
            <tr>
                <td> EditableOn: </td>
                <td>
                    <div id="dropDown"></div>
                </td>
            </tr>
            <tr>
                <td  class="sample-td"> Enter your name: </td>
                <td  class="sample-td">
                    <div id="element"></div>
                </td>
            </tr>
        </table>
    </div>
</body>

</html>

Action on focus out

Action to be performed when the user clicks outside the container, that means focusing out of editable content and it can be handled by the actionOnBlur property, by default Submit assigned. It also has the following options.

  • Cancel: Cancels the editing and resets the old content.
  • Submit: Submits the edited content to the server.
  • Ignore: No action is performed with this type and allows to edit multiple editors.

In the following sample, when switching drop-down item, the selected value assigned to the actionOnBlur property.

import { InPlaceEditor, ActionBlur } from '@syncfusion/ej2-inplace-editor';
import { DropDownList, ChangeEventArgs } from '@syncfusion/ej2-dropdowns';

let blurActionData: string[] = ['Submit', 'Cancel', 'Ignore'];

let dropDownObj: DropDownList = new DropDownList({
    dataSource: blurActionData,
    width: 'auto',
    value: 'Submit',
    change: onChange,
    placeholder: 'Select blur action'
});
dropDownObj.appendTo('#dropDown')

let editObj: InPlaceEditor = new InPlaceEditor({
    mode: 'Inline',
    value: 'Andrew',
    model: {
        placeholder: 'Enter some text'
    }
});
editObj.appendTo('#element');

function onChange(e: ChangeEventArgs): void {
    let editType: ActionBlur = e.itemData.value as ActionBlur;
    editObj.actionOnBlur = editType;
    editObj.dataBind();
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 In-place Editor</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript In-place Editor Control" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <table class="table-section">
            <tr>
                <td> ActionOnBlur: </td>
                <td>
                    <div id="dropDown"></div>
                </td>
            </tr>
            <tr>
                <td  class="sample-td"> Enter your name: </td>
                <td  class="sample-td">
                    <div id="element"></div>
                </td>
            </tr>
        </table>
    </div>
</body>

</html>

Display modes

By default, In-place Editor input element highlighted with a dotted underline. To remove dotted underline from input element, add data-underline="false" attribute at In-place Editor root element.

In the following sample, denotes to indicate intractable and normal display modes with different samples.

import { InPlaceEditor, ActionBlur } from '@syncfusion/ej2-inplace-editor';

let defaultObj: InPlaceEditor = new InPlaceEditor({
    mode: 'Inline',
    value: 'Andrew',
    model: {
        placeholder: 'Enter some text'
    }
});
defaultObj.appendTo('#default');

let inlineObj: InPlaceEditor = new InPlaceEditor({
    mode: 'Inline',
    value: 'Andrew',
    model: {
        placeholder: 'Enter some text'
    }
});
inlineObj.appendTo('#inline');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 In-place Editor</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript In-place Editor Control" />
    <meta name="author" content="Syncfusion" />
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <h4>Example of data-underline attribute</h4>
        <table class="table-section">
            <tr>
                <td class="col-lg-6 col-md-6 col-sm-6 col-xs-6 control-title"> Intractable UI </td>
                <td class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                    <div id="default"></div>
                </td>
            </tr>
            <tr>
                <td class="col-lg-6 col-md-6 col-sm-6 col-xs-6 control-title"> Normal UI </td>
                <td class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                    <div id="inline" data-underline="false"></div>
                </td>
            </tr>
        </table>
    </div>
</body>

</html>

See Also