Skip to main content

MVCxTreeListSettingsEditing.DeleteNodeRouteValues Property

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

Namespace: DevExpress.Web.Mvc

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

NuGet Package: DevExpress.Web.Mvc5

Declaration

public object DeleteNodeRouteValues { 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 DeleteNodeRouteValues
MVCxTreeList
.SettingsEditing .DeleteNodeRouteValues
TreeListSettings
.SettingsEditing .DeleteNodeRouteValues

Remarks

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

Note that in an action that handles delete operations, you can obtain the key value of the deleted row.

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