Configuration

21 Dec 202215 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

NOTE

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.

@using Syncfusion.EJ2.InPlaceEditor;

<div id='container'>
    <table class="table-section">
        <tr>
            <td> Mode: </td>
            <td>
                @Html.EJS().DropDownList("dropDown").Width("auto").DataSource(ViewBag.modeData).Value(ViewBag.value).Change("onChange").Placeholder("Select Mode").Render()
            </td>
        </tr>
        <tr>
            <td class="sample-td"> Enter your name: </td>
            <td class="sample-td">
                @Html.EJS().InPlaceEditor("element").Mode(RenderMode.Inline).Value("Andrew").Model(ViewBag.modelData).Render()
            </td>
        </tr>
    </table>
</div>

<style>
    .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>

<script>
    function onChange(e) {
        var editObj = document.getElementById('element').ej2_instances[0];
        var mode = e.itemData.value;
        editObj.mode = mode;
        editObj.dataBind();
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.modeData = new string[] { "Inline", "Popup" };
        ViewBag.value = "Inline";
        ViewBag.modalData = new { placeholder = "Enter some text" };
        return View();
    }
}

The output will be as follows.

Modes

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 Syncfusion ASP.NET MVC Tooltip control, so you can use tooltip properties and events to customize the behavior of popup via the Model property of PopupSettings API.

NOTE

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
@using Syncfusion.EJ2.InPlaceEditor;

<div id='container'>
    <table class="table-section">
        <tr>
            <td> Position: </td>
            <td>
                @Html.EJS().DropDownList("dropDown").DataSource(ViewBag.positionData).Value(ViewBag.text).Change("onChange").Placeholder("Select a position").PopupHeight("150px").Render()
            </td>
        </tr>
        <tr>
            <td class="edit-heading sample-td"> Enter your name: </td>
            <td class="sample-td">
                @Html.EJS().InPlaceEditor("element").PopupSettings(e=>e.Title("Enter name").Model(ViewBag.model)).Mode(RenderMode.Popup).Value(ViewBag.textValue).Model(ViewBag.modelData).Render()
            </td>
        </tr>
    </table>
</div>

<style>
    #container {
        display: flex;
        justify-content: center;
    }

    .table-section {
        margin: 0 auto;
    }

    .sample-td {
        padding-top: 150px;
    }

    .edit-heading {
        padding-right: 20px;
    }
</style>
<script>
    function onChange(e) {
        var editObj = document.getElementById('element').ej2_instances[0];
        editObj.popupSettings.model.position = e.value;
        editObj.dataBind();
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.positionData = new string[] { "TopLeft", "TopCenter", "TopRight", "BottomLeft", "BottomCenter", "BottomRight", "LeftTop", "LeftCenter", "LeftBottom", "RightTop", "RightCenter", "RightBottom" };
        ViewBag.modelData = new { placeholder = "Enter some text" };
        ViewBag.text = "BottomCenter";
        ViewBag.textValue = "Andrew";
        ViewBag.model = new { position = "BottomCenter" };
        return View();
    }
}

The output will be as follows.

Popup

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.

NOTE

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.

@using Syncfusion.EJ2.InPlaceEditor;

<div id='container'>
    <table class="table-section">
        <tr>
            <td> EditableOn: </td>
            <td>
                @Html.EJS().DropDownList("dropDown").Width("auto").DataSource(ViewBag.editableOnData).Value(ViewBag.text).Change("onChange").Placeholder("Select edit type").Render()
            </td>
        </tr>
        <tr>
            <td class="sample-td"> Enter your name: </td>
            <td class="sample-td">
                @Html.EJS().InPlaceEditor("element").Mode(RenderMode.Inline).Value(ViewBag.textValue).Locale("fr-BE").Model(ViewBag.modelData).Render()
            </td>
        </tr>
    </table>
</div>

<style>

    .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>
<script>
    function onChange(e) {
        var editObj = document.getElementById('element').ej2_instances[0];
        var editType = e.itemData.value;
        editObj.editableOn = editType;
        editObj.dataBind();
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.modelData = new { placeholder = "Enter some text" };
        ViewBag.editableOnData = new string[] { "Click", "DblClick", "EditIconClick" };
        ViewBag.text = "Click";
        ViewBag.textValue = "Andrew";
        return View();
    }
}

The output will be as follows.

Editable-on

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.

<div id='container'>
    <table class="table-section">
        <tr>
            <td> ActionOnBlur: </td>
            <td>
                @Html.EJS().DropDownList("dropDown").DataSource(ViewBag.blurActionData).Width("auto").Value(ViewBag.text).Change("onChange").Placeholder("Select blur action").Render()
            </td>
        </tr>
        <tr>
            <td class="sample-td"> Enter your name: </td>
            <td class="sample-td">
                @Html.EJS().InPlaceEditor("element").Mode(Syncfusion.EJ2.InPlaceEditor.RenderMode.Inline).Value(ViewBag.textValue).Model(ViewBag.modelData).Render()
            </td>
        </tr>
    </table>
</div>

<style>

    .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>
<script>
    function onChange(e) {
        var editObj = document.getElementById('element').ej2_instances[0];
        let editType = e.itemData.value;
        editObj.actionOnBlur = editType;
        editObj.dataBind();
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.blurActionData = new string[] { "Submit", "Cancel", "Ignore" };
        ViewBag.modelData = new { placeholder = "Enter some text" };
        ViewBag.text = "Submit";
        ViewBag.textValue = "Andrew";
        return View();
    }
}

The output will be as follows.

Action-on-blur

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.

@using Syncfusion.EJ2.InPlaceEditor;

<div id='container'>
    <h4>Example of data-underline attribute</h4>
    <table class="table-section">
        <tr>
            <td class="col-lg-6 control-title"> Intractable UI </td>
            <td class="col-lg-6">
                @Html.EJS().InPlaceEditor("element").Mode(RenderMode.Inline).Value(ViewBag.textValue).Model(ViewBag.modelData).Render()
            </td>
        </tr>
        <tr>
            <td class="col-lg-6 control-title"> Normal UI </td>
            <td class="col-lg-6">
                @Html.EJS().InPlaceEditor("inline").Mode(RenderMode.Inline).Value(ViewBag.textValue).Model(ViewBag.modelData).Created("created").Render()
            </td>
        </tr>
    </table>
</div>

<style>
    .table-section {
        margin: 0 auto;
    }

    td {
        padding: 20px 0;
        min-width: 230px;
        height: 100px;
    }

    .control-title {
        font-weight: 600;
        padding-right: 20px;
        text-align: right;
    }

    h4 {
        text-align: center;
    }
</style>
<script>
    function created() {
        document.getElementById("inline").setAttribute("data-underline", "false");
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.modelData = new { placeholder = "Enter some text" };
        ViewBag.textValue = "Andrew";
        return View();
    }
}

The output will be as follows.

Underline