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

drag and drop between grids with collection data

2 Answers 83 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Valko
Top achievements
Rank 1
Valko asked on 29 Sep 2012, 10:49 AM
Hello,

is there any way to achieve WPF .NET 4 drag and drop between grids with different data, for example on the left grid (drag source) you have products and on the right grid (drop target) we have Orders, Orders has Name and Date plus collection of Products, Order
grid can be grouped with expand collapse by Products list (we can hide or show all Products within an Order), and finally we can drag Product from left grid to particular Order in the right grid?

Orders grid looks like this (it has expandable childtemplate with Products):
<telerikGrid:RadGridView x:Name="TelerikOrdersGrid" AutoGenerateColumns="False" ShowGroupPanel="False" Grid.Column="0">
           <telerikGrid:RadGridView.Columns>
               <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="100" />
           </telerikGrid:RadGridView.Columns>
           <telerikGrid:RadGridView.ChildTableDefinitions>
               <telerikGrid:GridViewTableDefinition />
           </telerikGrid:RadGridView.ChildTableDefinitions>
           <telerikGrid:RadGridView.HierarchyChildTemplate>
               <DataTemplate>
                   <telerikGrid:RadGridView x:Name="TelerikProductsGrid" telerikDragDrop:RadDragAndDropManager.AllowDrop="True" AutoGenerateColumns="False" ShowGroupPanel="False" ItemsSource="{Binding Products}">
                       <telerikGrid:RadGridView.Columns>
                           <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding ProductName}" Width="100" />
                       </telerikGrid:RadGridView.Columns>
                   </telerikGrid:RadGridView>
               </DataTemplate>
           </telerikGrid:RadGridView.HierarchyChildTemplate>
       </telerikGrid:RadGridView>

How exactly I register RadDragAndDropManager.AddDropQueryHandler for TelerikDetailGrid?

When I try in code behind:

RadDragAndDropManager.AddDropQueryHandler(TelerikDetailGrid, RadGridView_OnDropQuery);


I have got error:

Error    1    The name 'TelerikDetailGrid' does not exist in the current context    C:\test\MainWindow.xaml.cs    35    55



In other words to add Product to Order by drag and drop? If possible by using multi-select - slecting one or more Product?

thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 01 Oct 2012, 05:24 AM
Hi,

 Your child grid is in a different name scope. You cannot access it directly!

Kind regards,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Valko
Top achievements
Rank 1
answered on 01 Oct 2012, 08:53 PM
Hello Vlad,

thank you, I just used initialisation for the child grid to add the drop handlers I need:


private void TelerikProductGrid_Initialized(object sender, EventArgs e)
        {
            RadDragAndDropManager.AddDropQueryHandler(((RadGridView) sender), RadGridView_OnDropQuery);
            RadDragAndDropManager.AddDropInfoHandler(((RadGridView)sender), RadGridView_OnDropInfo);
        }


Regards

Valko
Tags
DragAndDrop
Asked by
Valko
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Valko
Top achievements
Rank 1
Share this question
or