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

Wrong order after drag-and-drop

5 Answers 33 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mathias
Top achievements
Rank 1
Mathias asked on 07 Oct 2015, 10:11 AM

Hey

 

We have a problem with the drag-and-drop feature of the RadComboBox:

The bug occurs when we have two ComboBoxes and in the OnChange event we sort the items of the first ComboBox. When we move now one item (for example the third) to the other ComboBox with drag-and-drop and then back to its initial position, the order of the items in the left ComboBox is wrong.

We currently us the version 2015.2.826.35 of Telerik.

Please see the attached files. Thank you very much!

 

Best regards,
Mathias

5 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 12 Oct 2015, 07:26 AM
Hello Mathias,

Just to make sure that we are on the same page - do you experience the described issue with the RadCombox or with the RadListBox? In the attached images, I can only revise an implementation of RadListBoxes. If the problem is regarding the RadComboBox. please provide us with the implementation that you use. In addition, it would be much easier for us to test your implementation, if it is provided with a code-snippet, instead of an image, describing the code.

Regards,
Nencho
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mathias
Top achievements
Rank 1
answered on 12 Oct 2015, 01:46 PM
Thanks for your replay, Nencho.
You're right, of course. The problem comes with the RadListBox, not the RadComboBox. Sorry for the confusion!
0
Mathias
Top achievements
Rank 1
answered on 12 Oct 2015, 01:49 PM

Here the code snippets.. I had problems with the Internet Explorer ;)

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadListBox_Sort.aspx.cs" Inherits="Post.Appl.Corp.Design.WPL_Telerik.Pages.Bugs.RadListBox_Sort" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title>RadListBox</title>
</head>
<body>
    <form id="form1" runat="server">
 
        <telerik:RadScriptManager ID="scriptManager" runat="server" />
 
        <telerik:RadListBox runat="server" ID="listSource"
            Width="20%" Height="200"
            EnableDragAndDrop="True"
            SelectionMode="Multiple"
            AllowReorder="False"
            AllowTransfer="True"
            TransferToID="listTarget"
            AutoPostBackOnTransfer="True"
            OnTransferred="OnChanged">
        </telerik:RadListBox>
 
        <telerik:RadListBox runat="server" ID="listTarget"
            Width="20%" Height="200"
            EnableDragAndDrop="True"
            SelectionMode="Multiple"
            AllowReorder="False"
            AllowTransfer="true"
            TransferToID="listSource">
            <ButtonSettings ShowTransfer="False" ShowTransferAll="False" />
        </telerik:RadListBox>
 
        <asp:Button runat="server" Text="Reset" OnClick="ResetClick" />
 
    </form>
</body>
</html>

Code-Behind:

using System;
using System.Web.UI;
using Telerik.Web.UI;
 
namespace Post.Appl.Corp.Design.WPL_Telerik.Pages.Bugs
{
    public partial class RadListBox_Sort : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitListBox();
            }
        }
         
        private void InitListBox()
        {
            listSource.Items.Clear();
            listTarget.Items.Clear();
 
            var item = new RadListBoxItem("1_Anna", "1");
            listSource.Items.Add(item);
            item = new RadListBoxItem("2_Astrid", "2");
            listSource.Items.Add(item);
            item = new RadListBoxItem("3_David", "3");
            listSource.Items.Add(item);
            item = new RadListBoxItem("4_Fred", "4");
            listSource.Items.Add(item);
            item = new RadListBoxItem("5_Goliath", "5");
            listSource.Items.Add(item);
            item = new RadListBoxItem("6_Hans", "6");
            listSource.Items.Add(item);
            item = new RadListBoxItem("7_Julian", "7");
            listSource.Items.Add(item);
        }
 
        protected void OnChanged(object sender, RadListBoxTransferredEventArgs e)
        {
            listSource.Items.Sort(x => x.Text);
        }
 
        protected void ResetClick(object sender, EventArgs e)
        {
            InitListBox();
        }
    }
}

0
Nencho
Telerik team
answered on 15 Oct 2015, 12:48 PM
Hello Mathias,

Indeed the custom sorting cannot be applied at this event handler, when the items are transferred using the drag&drop functionality. There is an internal logic applying the indexation of the items, which prevents the sorting from execution.

In order to achieve the desired functionality, I would suggest to you to apply the sorting at the Page_PreRender state of the page's Lifecycle:

protected void Page_PreRender(object sender, EventArgs e)
    {
        listSource.Items.Sort(x => x.Text);
           listSource.DataBind();
    }

Regards,
Nencho
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mathias
Top achievements
Rank 1
answered on 19 Oct 2015, 11:58 AM

Hi Nencho

Thank you very much for your solution.
It worked :)

Best regards,
Mathias

Tags
ComboBox
Asked by
Mathias
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Mathias
Top achievements
Rank 1
Share this question
or