New to Telerik UI for ASP.NET Core? Download free 30-day trial

Editing by Dragging and Dropping

Currently, the dragging and dropping of items (.Editable(editable=>editable.Move(true)) and .Editable(editable=>editable.Move(move => move.Reorderable(true)))) is not supported with the incell edit mode of the TreeList because the draggable functionality prevents the mousedown event. As a result, the change event of the editor input does not fire, which in turn prevents the MVVM binding from saving the updated value. To work around this problem, refer to this GitHub issue.

When the .Editable(editable=>editable.Move(true)) property is set to true, the user can drag and drop the rows and the TreeList internally updates the ParentId field. Setting the .Editable(editable=>editable.Move(move => move.Reorderable(true))) property to true enables users not only to move items to a different level in the hierarchy but also allows users to reorder items within a particular hierarchy level.

To persist the new hierarchy, configure the TreeList data source for CRUD operations and set transport.update as a bare minimum. For a runnable example, refer to the demo on editing by dragging and dropping the rows of the TreeList.

        .Editable(editable => editable.Move(move => move.Reorderable(true))
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("Employees_Read", "TreeList"))
            .Update(update => update.Action("Employees_Update", "TreeList"))
            .Model(m =>
                m.Id(f => f.OrderID);
                m.ParentId(f => f.ParentOrderID).Nullable(true);
        /* other TreeList settings */
    <kendo-treelist name="treelist">
        <editable enabled="true">
            <move reorderable="true"/>
                <read url="@Url.Action("Employees_Read","TreeList")"/>
                <update url="@Url.Action("Employees_Update","TreeList")"/>
            <schema data="Data" total="Total" errors="Errors">
                <treelist-model id="OrderID" parent-id="ParentOrderID" expanded="true">
                        <field name="OrderID" type="number"></field>
                        <field name="ParentOrderID" nullable="true" type="number"></field>
    // The TreeList sends the updated items with prefix "models".
  // Remember to bind it in the controller so that the collection can be intercepted.
    public JsonResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<EmployeeDirectoryModel> employees).
        if (ModelState.IsValid)
            foreach (var employee in employees)
                employeeDirectory.Update(employee, ModelState);

        return Json(employees.ToTreeDataSourceResult(request, ModelState));

See Also

In this article