Skip to main content

MVCxTreeListSettingsEditing.NodeDragDropRouteValues Property

Defines the callback routing logic by specifying the names of a Controller and an Action which should handle callbacks related to moving a row.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public object NodeDragDropRouteValues { get; set; }

Property Value

Type Description
Object

An object containing the Controller and Action names.

Property Paths

You can access this nested property as listed below:

Object Type Path to NodeDragDropRouteValues
MVCxTreeList
.SettingsEditing .NodeDragDropRouteValues
TreeListSettings
.SettingsEditing .NodeDragDropRouteValues

Remarks

If moving a row is allowed for the TreeList, you should provide an associated controller action that will apply move operations to a Model and return the treelist’s partial view. Use the NodeDragDropRouteValues property to reference this controller action by its name and the name of its controller.

Note that moving a row is an edit operation, because the node’s parent node id is changed.

The code sample below demonstrates how to define route values in order to enable editing operations within the TreeList.

@{
    var treeList = Html.DevExpress().TreeList(
        settings => {
            settings.Name = "treeList";
            settings.CallbackRouteValues = new { Controller = "TreeList", Action = "InlineEditingPartial" };

            settings.Columns.Add("From");
            ...
            settings.CommandColumn.Visible = true;
            settings.CommandColumn.ShowNewButtonInHeader = true;
            settings.CommandColumn.NewButton.Visible = true;
            settings.CommandColumn.DeleteButton.Visible = true;
            settings.CommandColumn.EditButton.Visible = true;

            settings.SettingsEditing.AddNewNodeRouteValues = new { Controller = "TreeList", Action = "InlineEditingAddNewPostPartial" };
            settings.SettingsEditing.UpdateNodeRouteValues = new { Controller = "TreeList", Action = "InlineEditingUpdatePostPartial" };
            settings.SettingsEditing.NodeDragDropRouteValues = new { Controller = "TreeList", Action = "InlineEditingMovePostPartial" };
            settings.SettingsEditing.DeleteNodeRouteValues = new { Controller = "TreeList", Action = "InlineEditingDeletePostPartial" };
            settings.SettingsEditing.ConfirmDelete = true;
            ...
            };
        }
    );
    if(ViewData["EditNodeError"] != null) {
        treeList.SetEditErrorText((string)ViewData["EditNodeError"]);
    }
}

@treeList.Bind(Model).GetHtml()
using System;
using System.Web.Mvc;
using DevExpress.Web.Mvc;

namespace DevExpress.Web.Demos {
    public partial class TreeListController : Controller {
        public ActionResult InlineEditing() {
            return View("InlineEditing", NewsGroupsProvider.GetEditablePosts());
        }
        [ValidateInput(false)]
        public ActionResult InlineEditingPartial() {
            return PartialView("InlineEditingPartial", NewsGroupsProvider.GetEditablePosts());
        }
        [HttpPost, ValidateInput(false)]
        public ActionResult InlineEditingAddNewPostPartial(EditablePost post) {
            if(ModelState.IsValid) {
                try {
                    NewsGroupsProvider.InsertPost(post);
                }
                catch(Exception e) {
                    ViewData["EditNodeError"] = e.Message;
                }
            }
            else
                ViewData["EditNodeError"] = "Please, correct all errors.";
            return PartialView("InlineEditingPartial", NewsGroupsProvider.GetEditablePosts());
        }
        [HttpPost, ValidateInput(false)]
        public ActionResult InlineEditingUpdatePostPartial(EditablePost post) {
            if(ModelState.IsValid) {
                try {
                    NewsGroupsProvider.UpdatePost(post);
                }
                catch(Exception e) {
                    ViewData["EditNodeError"] = e.Message;
                }
            }
            else
                ViewData["EditNodeError"] = "Please, correct all errors.";
            return PartialView("InlineEditingPartial", NewsGroupsProvider.GetEditablePosts());
        }
        [HttpPost, ValidateInput(false)]
        public ActionResult InlineEditingMovePostPartial(int postID, int? parentID) {
            NewsGroupsProvider.MovePost(postID, parentID);
            return PartialView("InlineEditingPartial", NewsGroupsProvider.GetEditablePosts());
        }
        [HttpPost, ValidateInput(false)]
        public ActionResult InlineEditingDeletePostPartial(int postID) {
            try {
                NewsGroupsProvider.DeletePost(postID);
            }
            catch(Exception e) {
                ViewData["EditNodeError"] = e.Message;
            }
            return PartialView("InlineEditingPartial", NewsGroupsProvider.GetEditablePosts());
        }
    }
}
See Also