drag and drop between grids with collection data

3 posts, 1 answers
  1. Valko
    Valko avatar
    2 posts
    Member since:
    Sep 2012

    Posted 29 Sep 2012 Link to this post

    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. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 01 Oct 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Valko
    Valko avatar
    2 posts
    Member since:
    Sep 2012

    Posted 01 Oct 2012 Link to this post

    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
Back to Top