Cell Editing in ASP.NET MVC Tree Grid Component

21 Dec 20221 minute to read

In Cell edit mode, when you double click on a cell, it is changed to edit state.
You can change the cell value and save to the data source.
To enable Cell edit, set the Mode property of EditSettings as Cell.

@using Syncfusion.EJ2.Grids

@(Html.EJS().TreeGrid("TreeGrid").DataSource((IEnumerable<object>)ViewBag.datasource)
      .EditSettings(edit =>
       {
        edit.AllowAdding(true);
        edit.AllowDeleting(true);
        edit.AllowEditing(true);
        edit.Mode(Syncfusion.EJ2.TreeGrid.EditMode.Cell);

       })
       .Toolbar(new List<string>() { "Add", "Delete", "Update", "Cancel" })
       .Columns(col =>
        {
          col.Field("TaskId").HeaderText("Task ID").IsPrimaryKey(true).Width(120)
             .TextAlign(TextAlign.Right).Add();
          col.Field("TaskName").HeaderText("Task Name").Add();
          col.Field("StartDate").HeaderText("Start Date").Width(150).Format("yMd")
             .EditType("datepickeredit").TextAlign(TextAlign.Right).Add();
          col.Field("Duration").HeaderText("Duration").Width("110").EditType("numericedit")
              .Edit(new { @params = new { format = "n" } }).TextAlign(TextAlign.Right).Add();

        }).Height(400).ChildMapping("Children").TreeColumnIndex(1).Render())
public IActionResult Index()
{
    var tree = TreeData.GetDefaultData();
    ViewBag.dataSource = tree;
    return View();
}

NOTE

Cell edit mode is default mode of editing.

You can refer to our ASP.NET MVC Tree Grid feature tour page for its groundbreaking feature representations. You can also explore our ASP.NET MVC Tree Grid example to knows how to present and manipulate data.