This is a migrated thread and some comments may be shown as answers.

Disable drag and drop for spesific nodes

1 Answer 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lars Melkevik
Top achievements
Rank 1
Lars Melkevik asked on 22 Sep 2008, 01:33 PM

Hi.

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:

Dim

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'"

Dim

adapter As New SqlDataAdapter(query, conn)

Dim

dataTable As New DataTable()

adapter.Fill(dataTable)

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

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

Best regards,
Lars Melkevik

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 22 Sep 2008, 01:45 PM
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">
            <DataBindings>
                <telerik:RadTreeNodeBinding AllowDragField="AllowDragField" />
            </DataBindings>
        </telerik:RadTreeView>

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Lars Melkevik
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or