Migration from RadDragDropManager to DragDropManager

2 posts, 0 answers
  1. wesley
    wesley avatar
    1 posts
    Member since:
    Feb 2019

    Posted 04 Feb Link to this post

    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;
                }
            }
  2. Dinko
    Admin
    Dinko avatar
    897 posts

    Posted 07 Feb Link to this post

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