Completed
Last Updated: 21 Mar 2019 15:04 by ADMIN
Release 2019.1.325 (03/25/2019)
ADMIN
Hristo
Created on: 07 Dec 2018 12:20
Category:
Type: Bug Report
1
FIX. RadListControl - exception while performing drag-and-drop with multiple items
How to reproduce: check the attached file

Workaround: create a custom drag-drop service 
public class CustomListControlDragDropService : ListControlDragDropService
{
    private RadListDataItem draggedItem;

    public CustomListControlDragDropService(RadListElement owner) 
        : base(owner)
    {
    }

    protected override void PerformStart()
    {
        base.PerformStart();

        RadListVisualItem draggedVisualItem = this.Context as RadListVisualItem;
        if (draggedVisualItem != null)
        {
            this.draggedItem = draggedVisualItem.Data;
        }
    }

    protected override void PerformStop()
    {
        base.PerformStop();

        this.DisposeHint();
        this.draggedItem = null;
    }

    protected override void OnPreviewDragDropCore(RadListElement targetList, RadListVisualItem targetElement)
    {
        int index = targetList.Items.Count - 1;
        if (targetElement != null)
        {
            index = targetList.Items.IndexOf(targetElement.Data);
        }
        
        if (this.draggedItem.Owner != targetList)
        {
            index++;
        }
        RadListElement dragedListView = this.draggedItem.Owner;

        IList<RadListDataItem> itemsToMove = new List<RadListDataItem>(dragedListView.SelectedItems.Count);

        foreach (RadListDataItem item in dragedListView.SelectedItems)
        {
            itemsToMove.Add(item);
        }

        dragedListView.BeginUpdate();
        foreach (RadListDataItem item in itemsToMove)
        {
            item.Selected =
                item.Active = false;
            dragedListView.Items.Remove(item);
        }

        dragedListView.EndUpdate();
        targetList.BeginUpdate();
        foreach (RadListDataItem item in itemsToMove)
        {
            if (index > targetList.Items.Count)
            {
                targetList.Items.Add(item);
            }
            else
            {
                targetList.Items.Insert(index, item);
            }

            item.Selected = item.Active = true;

            index++;
        }

        targetList.EndUpdate();
    }
}
Attached Files:
1 comment
Dimitar
Posted on: 21 Mar 2019 15:03
Hello, 
 
A Fix will be available in LIB Version 2019.1.325 scheduled for March 25th.

Best regards, 
Dimitar