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

Migration from RadDragDropManager to DragDropManager

1 Answer 53 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
wesley
Top achievements
Rank 1
wesley asked on 04 Feb 2019, 08:33 PM
I've ready through the migration guide, overview, and DragDropPayloadManager guides, but there is still not enough information to migrate my existing code.Even the migration guide isn't sure which event maps to which event (see attached photo).

Can someone familiar with making the migration help me port over this code since basically everything has changed?

        public void OnDragInfo(object sender, DragDropEventArgs e)
        {
            if (e.Options.Status == DragStatus.DropImpossible && DragCue != null)
            {
                DragCue.Background = DropImpossibleBackground;
                DropIndicator.Opacity = 0;
            }
            else if (DragCue != null)
            {
                DragCue.Background = DropPossibleBackground;

                DropIndicator.HorizontalOffset = e.Options.CurrentDragPoint.X - e.Options.RelativeDragPoint.X;
                DropIndicator.VerticalOffset = e.Options.CurrentDragPoint.Y - e.Options.RelativeDragPoint.Y + DropIndicator.Height;
                Debug.WriteLine(e.Options.CurrentDragPoint);
                DropIndicator.Opacity = 100;
            }
        }

        public void OnDragQuery(object sender, DragDropQueryEventArgs e)
        {
            GridViewRow row = sender as GridViewRow;

            e.QueryResult = RadDragAndDropManager.GetAllowDrag(row) &&
                (e.Options.Destination == null || e.Options.Destination is GridViewRow);

            if ((e.QueryResult ?? false) && e.Options.Status == DragStatus.DragQuery)
            {
                e.Options.Payload = row?.DataContext;
            }
        }

        public void OnDropInfo(object sender, DragDropEventArgs e)
        {
            object item = e.Options.Payload;
            GridViewRow source = e.Options.Source as GridViewRow;
            GridViewRow destination = e.Options.Destination as GridViewRow;

            if (source != null && destination != null && AssociatedObject.Items.Contains(item) && e.Options.Status == DragStatus.DragComplete)
            {
                int index = AssociatedObject.ItemContainerGenerator.IndexFromContainer(destination);

                ((IList) AssociatedObject.ItemsSource).Remove(item);

                ((IList) AssociatedObject.ItemsSource).Insert(index, item);

                if (!ItemsSourceSupportNotifications)
                {
                    AssociatedObject.Rebind();
                }

                DropIndicator.IsOpen = false;
            }

            if (e.Options.Status == DragStatus.DragCancel)
            {
                DropIndicator.IsOpen = false;
            }
        }

        public void OnDropQuery(object sender, DragDropQueryEventArgs e)
        {
            GridViewRow targetRow = e.Options.Destination as GridViewRow;

            if (targetRow != null)
            {
                e.QueryResult = targetRow.GridViewDataControl == AssociatedObject;
            }
            else
            {
                e.QueryResult = false;
            }
        }

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 07 Feb 2019, 11:16 AM
Hi Regulus,

I am sorry to hear that the migration article was not helpful enough.

You can try using the following events as a replacement. 
  • OnDragInfo -> GiveFeedback 
  • OnDragQuery -> DragInitialize
  • OnDropInfo -> Drop
  • OnDropQuery -> DragOver 

You can take a look at DragDropManager Events article which lists and described all events of the new drag-drop manager.

Give this a try and let me know if further questions arise.

Regards,

Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DragAndDrop
Asked by
wesley
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or