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

Detect day on drag/drop from RadGridView

1 Answer 10 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Elsa
Top achievements
Rank 1
Elsa asked on 29 Apr 2014, 04:32 PM
Greetings.

I'm experimenting with the latest demo version and running into an issue.  Mind you, this seems like an edge case based on what I've read from others, but hopefully you can guide me.

I have an unbound RadGridView.  It's unbound because I need to support drag/drop resorting within itself, simple inline editing and drag/drop to a RadCalendar.  All of this is functioning well  (I made extensive use of various how-tos on drag/drop from RadGridViews).

However, when I drag a row from the RadGridView to the RadCalendar, I'm unable to detect what day I've dragged the row onto.  This would be trivial if I were using the drag/drop events of the Calendar itself, but I'm not.  I'm using the Drag/Drop services I've declared as part of my extended RadGridView (similar to the documentation here:  http://blogs.telerik.com/winformsteam/posts/13-05-15/extending-radgridview-to-enable-row-drag-and-drop-functionality )

My drop event looks like this...
 
private void dragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
       {
           Console.WriteLine(e.HitTarget);
           var el = e.HitTarget as RadCalendarElement;
           if (el != null)
           {
               GridDataRowElement draggedRow = ((SnapshotDragItem)e.DragInstance).Item as GridDataRowElement;
 
               if (draggedRow != null)
               {
                   int TaskID = (int)draggedRow.Data.Cells["TaskID"].Value;
                   // determine the date we dragged to, and update the task.
                   return;
               }
           }

How can I figure out which day I dropped the row onto?  I don't seem to be able to get anything out of RadCalendarElement, nor can I find a relevant CalendarCellElement.  Help!  :)

Thanks,
Elsa


1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 01 May 2014, 06:38 AM
Hi Elsa,

Thank you for writing.

In this case you can recreate your PreviewDragDrop event handler to look like the following one:
void svc_PreviewDragDrop(object sender, RadDropEventArgs e)
{
    RadCalendarElement el = e.HitTarget as RadCalendarElement;
 
    if (el != null)
    {
        GridDataRowElement dragedRow = ((SnapshotDragItem)e.DragInstance).Item as GridDataRowElement;
         
        if (dragedRow != null)
        {
            var date = el.ElementTree.GetElementAtPoint(e.DropLocation);
            el.Calendar.FocusedDate = DateTime.Parse(date.ToString());
        }
    }
}

The key point is the using of the GetElementAtPoint method which is used for the exact date element retrieval.

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Elsa
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or