Search results

Buttons

The In-place Editor had an action for save and cancel using buttons. The SaveButton and CancelButton properties accept the ButtonModel objects for customizing the save and cancel button properties.

Buttons can be show or hide by sets a Boolean value to the ShowButtons property.

Without buttons value will be processed via the following ways.

  • ActionOnBlur: By clicking out side the editor control get focus out and do action based on this property value.
  • SubmitOnEnter: Pressing Enter key it performs the submit action, if this property set to true.

In the following sample, the content and cssClass properties of Button value assigned to the SaveButton and CancelButton properties to customize its appearance. Also check or uncheck a checkbox buttons render or removed from the editor.

To restrict either save or cancel button rendering into a DOM, simply pass empty object {} in the SaveButton or CancelButton properties.

For more details about buttons, refer this documentation section.

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

<div id='container'>
    <table class="table-section">
        <tr>
            <td> ShowButtons: </td>
            <td>
                @Html.EJS().CheckBox("enableBtn").Change("onChange").Checked(true).Label("Show").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).Model(ViewBag.modelData).SaveButton(ViewBag.saveButton).CancelButton(ViewBag.cancelButton).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.showButtons = e.checked;
        editObj.dataBind();
    }
</script>
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.modalData = new { placeholder = "Enter some text" };
        ViewBag.saveButton = new { content = "Ok", cssClass = "e-outline" };
        ViewBag.cancelButton = new { content = "Cancel", cssClass = "e-outline" };
        ViewBag.textValue = "Andrew";
        return View();
    }
}

The output will be as follows.

showButton

See Also