Disable drag and drop for spesific nodes

2 posts, 0 answers
  1. Lars Melkevik
    Lars Melkevik avatar
    7 posts
    Member since:
    May 2005

    Posted 22 Sep 2008 Link to this post


    Please help! How do I disable drag and drop for a single node when the treeview is loaded from a database?

    When the database-column "dragdrop" is set to "false" for a node, drag and drop for that node should be disabled.

    This is how I load the treeview from the database:


    conn As New SqlConnection("Server=xxx.xxx.xxx.xxx;Database=treeview;User ID=xxxxxx;Password=xxxxxx;Trusted_Connection=False")

    Dim query As String = "SELECT * FROM treeview_nodes'"


    adapter As New SqlDataAdapter(query, conn)


    dataTable As New DataTable()


    nnNO.DataSource = dataTable_nnNO
    nnNO.DataFieldID =
    nnNO.DataFieldParentID = "parentId"
    nnNO.DataTextField = "Text"
    nnNO.DataNavigateUrlField = "Href"
    nbNO.DataValueField = "value"

    I assume I must use RadTreeView_NodeDataBound or something... Example code would be great!

    Best regards,
    Lars Melkevik

  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 22 Sep 2008 Link to this post

    Hi Lars Melkevik,

    Indeed you can subscribe to the NodeDataBound field. Then you need to set the AllowDrag property of the node depending on the database value. Alternatively you could use a node binding to tell RadTreeView which database field provides data for the AllowDrag property:

            <telerik:RadTreeView runat="server" ID="RadTreeView1">
                    <telerik:RadTreeNodeBinding AllowDragField="AllowDragField" />

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top