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

How to determine target row in hierarchical grid drop target?

4 Answers 126 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Lynne
Top achievements
Rank 1
Lynne asked on 01 Sep 2011, 11:55 PM
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?

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Sep 2011, 01:39 PM
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 >>

0
Lynne
Top achievements
Rank 1
answered on 05 Sep 2011, 07:33 PM
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?
0
Maya
Telerik team
answered on 08 Sep 2011, 12:50 PM
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 >>

0
Lynne
Top achievements
Rank 1
answered on 08 Sep 2011, 08:32 PM
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.
Tags
DragAndDrop
Asked by
Lynne
Top achievements
Rank 1
Answers by
Maya
Telerik team
Lynne
Top achievements
Rank 1
Lynne
Top achievements
Rank 1
Share this question
or