Akhil Dwivedi
Top achievements
Rank 1
Akhil Dwivedi
asked on 30 Oct 2009, 09:46 AM
Hi
i an usin treeview. How can i stop dragdrop between nodes but requies drag drop within a node item.
like
NodeA
A
B
C
D
NodeB
E
F
G
H
The item should be dragging within items of NodeA not within Item of NodeA and NodeB
i an usin treeview. How can i stop dragdrop between nodes but requies drag drop within a node item.
like
NodeA
A
B
C
D
NodeB
E
F
G
H
The item should be dragging within items of NodeA not within Item of NodeA and NodeB
3 Answers, 1 is accepted
0
Hello Akhil Dwivedi,
If I understand you correctly you want to use Drag/Drop only between items that are in the same TreeViewItem node and to disable Drag/Drop between items which are in different nodes.
If so please take a look at the following :
1.Define some RadTreeView and attach to PreviewDragEnded event.
<telerik:RadTreeView IsDragDropEnabled="True" PreviewDragEnded="RadTreeView_PreviewDragEnded" >
<telerik:RadTreeViewItem Header="A" IsExpanded="True" x:Name="NodeA">
<telerik:RadTreeViewItem Header="E" IsExpanded="True"/>
<telerik:RadTreeViewItem Header="C" />
<telerik:RadTreeViewItem Header="D" />
</telerik:RadTreeViewItem>
<telerik:RadTreeViewItem Header="B" IsExpanded="True">
<telerik:RadTreeViewItem Header="F"/>
<telerik:RadTreeViewItem Header="G" />
<telerik:RadTreeViewItem Header="H" />
</telerik:RadTreeViewItem>
</telerik:RadTreeView>
2.Add the following in code behind:
private void RadTreeView_PreviewDragEnded(object sender, Telerik.Windows.Controls.RadTreeViewDragEndedEventArgs e)
{
var treeViewItemDestination = e.TargetDropItem;
if (treeViewItemDestination == null || treeViewItemDestination.ParentItem != this.NodeA)
{
e.Handled = true;
}
}
That is all you have to do in order to accomplish the desired functionality.
So if you follow the above steps then you will be able to Drag/Drop only between the items in node A.
And if you try to Drag/Drop items from node A to node B then nothing happens.
I hope that this will help you.
Regards,
Boryana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
If I understand you correctly you want to use Drag/Drop only between items that are in the same TreeViewItem node and to disable Drag/Drop between items which are in different nodes.
If so please take a look at the following :
1.Define some RadTreeView and attach to PreviewDragEnded event.
<telerik:RadTreeView IsDragDropEnabled="True" PreviewDragEnded="RadTreeView_PreviewDragEnded" >
<telerik:RadTreeViewItem Header="A" IsExpanded="True" x:Name="NodeA">
<telerik:RadTreeViewItem Header="E" IsExpanded="True"/>
<telerik:RadTreeViewItem Header="C" />
<telerik:RadTreeViewItem Header="D" />
</telerik:RadTreeViewItem>
<telerik:RadTreeViewItem Header="B" IsExpanded="True">
<telerik:RadTreeViewItem Header="F"/>
<telerik:RadTreeViewItem Header="G" />
<telerik:RadTreeViewItem Header="H" />
</telerik:RadTreeViewItem>
</telerik:RadTreeView>
2.Add the following in code behind:
private void RadTreeView_PreviewDragEnded(object sender, Telerik.Windows.Controls.RadTreeViewDragEndedEventArgs e)
{
var treeViewItemDestination = e.TargetDropItem;
if (treeViewItemDestination == null || treeViewItemDestination.ParentItem != this.NodeA)
{
e.Handled = true;
}
}
That is all you have to do in order to accomplish the desired functionality.
So if you follow the above steps then you will be able to Drag/Drop only between the items in node A.
And if you try to Drag/Drop items from node A to node B then nothing happens.
I hope that this will help you.
Regards,
Boryana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Akhil Dwivedi
Top achievements
Rank 1
answered on 04 Nov 2009, 09:27 AM
Thanks for ur reply
It is fine for node A only but these parent nodes and child items are dynamic so how for others?
It is fine for node A only but these parent nodes and child items are dynamic so how for others?
0
Hello Akhil Dwivedi,
The important here is to subscribe to :
private void RadTreeView_PreviewDragEnded(object sender, Telerik.Windows.Controls.RadTreeViewDragEndedEventArgs e)
{
var treeViewItemDestination = e.TargetDropItem;
if (treeViewItemDestination == null || treeViewItemDestination.ParentItem != this.NodeA)
{
e.Handled = true;
}
}
Here you can define your own logic , I mean a particular condition showing whether user can drop item or not. Alternatively you can use the Item level for a condition or something similar.
You can also take a look at our online example:
http://demos.telerik.com/silverlight/#TreeView/DragDrop
I hope that this will be helpful.
Kind regards,
Boryana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The important here is to subscribe to :
private void RadTreeView_PreviewDragEnded(object sender, Telerik.Windows.Controls.RadTreeViewDragEndedEventArgs e)
{
var treeViewItemDestination = e.TargetDropItem;
if (treeViewItemDestination == null || treeViewItemDestination.ParentItem != this.NodeA)
{
e.Handled = true;
}
}
Here you can define your own logic , I mean a particular condition showing whether user can drop item or not. Alternatively you can use the Item level for a condition or something similar.
You can also take a look at our online example:
http://demos.telerik.com/silverlight/#TreeView/DragDrop
I hope that this will be helpful.
Kind regards,
Boryana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.