How to determine target row in hierarchical grid drop target?

5 posts, 0 answers
  1. Lynne
    Lynne avatar
    16 posts
    Member since:
    Feb 2011

    Posted 01 Sep 2011 Link to this post

    I'm dragging and dropping from one of two RadGridViews (Players and Teams) to another RadGridView (Games) which is configured as a 2-level-deep hierarchical grid.  I'm trying to allow users to drag Teams to a Game row and then Players to Game rows, as below:


    1. Team A
    2. Team B
    3. Team C
    • Game A
      • Team A
        • Player A
        • Player B
      • Team B
        • Player C
      • Team C
    • Game B
      • Team A
      • Team B
        • Player A
        • Player G

    1. Player A
    2. Player B
    3. Player C





    How can I determine which row has had (or is about to have) something dropped on it?

    I've tried your example that uses

    private void RadGridView_Drop(object sender, DragEventArgs e) {
        var destinationRow = SampleGrid.GetElementsInHostCoordinates<GridViewRow>(Mouse.GetPosition(null)).First();
     
        if (destinationRow != null) {
            MessageBox.Show("Dropped on row:" + ((IList) SampleGrid.ItemsSource).IndexOf(destinationRow.DataContext));
        }
    }


    but it doesn't work, if for no other reason than that Mouse.GetPosition(null) always returns {0,0} if the drag cue is non-null.

    How can I determine which target row the droppable object is over at any given time?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Sep 2011 Link to this post

    Hello Lynne,

    You may use the Destination property of the Options arguments in the DropQuery event. Please take a look at this, this or this articles for a reference. You may also run through our demos for additional examples.
     

    Kind regards,
    Maya
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Lynne
    Lynne avatar
    16 posts
    Member since:
    Feb 2011

    Posted 05 Sep 2011 Link to this post

    How do I determine which row the mouse is over?  The Destination property seems to be referring to the actual object in the row, and not the row.  None of the examples you've cited seem to show this, or else I've missed the point of your answer.

    I tried this:

    but mouseOverRow is always null.  I'm also seeing that I can get the Enter events, unless I'm dragging something, in which case I don't get the MouseEnter event until I drop the item (release the mouse button).  Worse, it only fires for the top level rows and none of the rows lower in the hierarchy.  

    The example cited for binding to IsExpandable is a dead link for me:
    http://blogs.telerik.com/server-error.aspx?aspxerrorpath=/silverlightteam/posts/10-06-03/how_-_to_bind_to_isexpandable_property_of_gridviewrow_in_radgridview_for_wpf_with_attached_behaviors.aspx

    In the target RadGridView, when I move an item over a row, or I drop an item, how do I determine which row I'm over, keeping in mind that the target is hierarchically arranged, which may or may not be expanded?
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Sep 2011 Link to this post

    Hi Lynne,

    The Destination property will return the element that has AllowDrop property set to true. So, in case you have the following style for example:

    <Style TargetType="telerik:GridViewRow">
                <Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True" />
                <Setter Property="telerik:RadDragAndDropManager.AllowDrop" Value="True" />
            </Style>
     
    The e.Options.Destination will return a GridViewRow (GVR). 
    Considering the blog post, please use this link instead.


    Kind regards,
    Maya
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Lynne
    Lynne avatar
    40 posts
    Member since:
    Sep 2011

    Posted 08 Sep 2011 Link to this post

    That's a reasonable workaround (and I've confirmed that I can get the information I need using it), but is there any other way?  I don't typically use styles like that.
Back to Top
UI for WPF is Visual Studio 2017 Ready