Search results

Dynamically move input to edit mode

At component 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 example, editor opened at initial load and when toggling a checkbox, it will remove or open the editor.

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.InPlaceEditor
@using Syncfusion.EJ2.Blazor.Buttons
@using Syncfusion.EJ2.Blazor.Inputs

<table class="table-section">
    <tr>
        <td> EnableEditMode: </td>
        <td>
            <EjsCheckBox Checked="false" Label="Disable" ></EjsCheckBox>
        </td>
    </tr>
    <tr>
        <td class="sample-td"> Enter your name: </td>
        <td class="sample-td">
            <EjsInPlaceEditor Mode="RenderMode.Inline" EnableEditMode="EditModeEnable" ActionOnBlur="ActionBlur.Ignore" Type="InputType.Text" Value="TextValue" SubmitOnEnter="true" Model="TModel">
            </EjsInPlaceEditor>
        </td>
    </tr>
</table>

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

@code {
    public bool EditModeEnable { get; set; } = true;
    public string TextValue = "Andrew";

    public TextBoxModel TModel = new TextBoxModel()
    {
        Placeholder = "Enter some text"
    };

    private void onChange(Syncfusion.EJ2.Blazor.Buttons.ChangeEventArgs args)
    {
        this.EditModeEnable = args.Checked;
        this.StateHasChanged();
    }
}