Wrong order after drag-and-drop

6 posts, 0 answers
  1. Mathias
    Mathias avatar
    9 posts
    Member since:
    Jun 2013

    Posted 07 Oct 2015 Link to this post

    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

  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 12 Oct 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mathias
    Mathias avatar
    9 posts
    Member since:
    Jun 2013

    Posted 12 Oct 2015 Link to this post

    Thanks for your replay, Nencho.
    You're right, of course. The problem comes with the RadListBox, not the RadComboBox. Sorry for the confusion!
  5. Mathias
    Mathias avatar
    9 posts
    Member since:
    Jun 2013

    Posted 12 Oct 2015 in reply to Nencho Link to this post

    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();
            }
        }
    }

  6. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 15 Oct 2015 Link to this post

    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
  7. Mathias
    Mathias avatar
    9 posts
    Member since:
    Jun 2013

    Posted 19 Oct 2015 in reply to Nencho Link to this post

    Hi Nencho

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

    Best regards,
    Mathias

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017