Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Collapse]Tree List
   [Expand]Product Information
   [Collapse]Concepts
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Expand]Data Editing
    [Expand]Data Shaping and Manipulation
     Drag and Drop
    [Expand]Focus and Navigation
     Appearance Customization
     Save and Restore Layout
    [Expand]Templates
     Toolbars
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Member Tables
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Drag and Drop

The ASPxTreeList supports drag and drop. You can allow end-users to move nodes via drag and drop either within an ASPxTreeList or between the ASPxTreeList and external controls. This can significantly increase the usability of your web application.

Note

If the ASPxTreeList is in edit mode, nodes are not allowed to be dragged.

Expanded End-User Drag-And-Drop

To enable drag and drop operations, turn on the TreeListSettingsEditing.AllowNodeDragDrop option. Once enabled, an end-user can drag a node and move it to the required position. The yellow arrow indicates a node to whose child collection the dragged node will be appended.

To move a node to the root, drag it to the header panel:

To cancel the drag and drop operation, press ESC.

Expanded Controlling Drag-And-Drop Operations

The ASPxTreeList provides two client-side and one server-side events that enable you to processes drag-and-drop operations.

  • The ASPxClientTreeList.StartDragNode event is raised before a user starts dragging a node. It enables you to specify target elements for the dragged node. When the dragged node hovers over a target, the arrow is displayed.
  • The ASPxClientTreeList.EndDragNode event is raised after a node drag and drop operation is completed.

    Both events allow you to cancel the operation by setting the event parameter's cancel property to true.

  • Finally, the server-side ASPxTreeList.ProcessDragNode event is raised and allows you to perform server-side processing, if required, or cancel the operation.

Expanded Example

This example demonstrates how to implement node dragging outside the ASPxTreeList. The ASPxClientTreeList.StartDragNode client event is handled to add the cart image to the list of target elements, so that an end-user can drag nodes to the cart. If a node has been dropped to the cart, the cart image changes (in the ASPxClientTreeList.EndDragNode client event handler) and the node is painted red (using the server ASPxTreeList.HtmlRowPrepared event).

The image below shows the result:

Expanded Moving Nodes In Code

To move nodes use the ASPxTreeList.MoveNode or ASPxClientTreeList.MoveNode method. The only requirement is the ASPxTreeList's ASPxTreeList.ParentFieldName property must be specified. Otherwise, calling the MoveTo method throws an exception.

Calling the MoveNode method raises the ASPxTreeList.ProcessDragNode event. This event allows you to cancel the drag and drop operation, or to manually process the operation. For an example, see How to: Perform Drag And Drop in Virtual Mode.

How would you rate this topic?​​​​​​​