Search results

Dynamically move input to edit mode

At control initial load, if you want to open editor state without interacting In-place Editor input element, it can be achieved by configuring the EnableEditMode property to true.

In the following sample, editor opened at initial load and when toggling a checkbox, it will remove or open the editor.

razor
controller.cs
@using Syncfusion.EJ2.InPlaceEditor;

<div id='container'>
    <table class="table-section">
        <tr>
            <td> Disabled: </td>
            <td>
                @Html.EJS().CheckBox("enable").Change("onChange").Label("Disable").Checked(false).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.value).Model(ViewBag.model).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];
        editObj.disabled = e.checked;
        editObj.dataBind();
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.model = new { placeholder = "Enter some text" };
        ViewBag.value = "Andrew";
        return View();
    }
}

The output will be as follows.

dynamic-edit