RadListBox drag and drop position problem

4 posts, 0 answers
  1. Meng
    Meng avatar
    57 posts
    Member since:
    Apr 2011

    Posted 14 Dec 2012 Link to this post

    Hi there,

    I am experiencing a problem when using drag and drop with Radlistboxes. 

    Here is the scenario:

    I drag an item from one Radlistbox and drop into the middle position of a second Radlistbox, When I iterate the items in the second Radlistbox using a foreach loop, it seems that the item I just dropped was iterated at the end of the loop. Isnt it suppose to be looped  in the middle? Any help or suggestions would be greatly appreciated.

    Thanks,
    Meng
  2. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 17 Dec 2012 Link to this post

    Hi Meng,

    I've tested the described scenario, but the problem did not reproduce on my end. Please take a look at the attached page and see if it works accordingly on your end. Also, please specify the version of the controls you are using.
     
    Regards,
    Bozhidar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Meng
    Meng avatar
    57 posts
    Member since:
    Apr 2011

    Posted 17 Dec 2012 Link to this post

    Hi Bozhidar,

    Thanks for your reply. In the example you provided, the listbox was looped in the button_click event. I am experiencing this issue in the OnTransferred event of ListBox1, please see the code below. If you drag one item to the second listbox, then drag it back to the middle position of the first listbox, the item was iterated at the end of the loop. Thank you. 

    <form id="form1" runat="server">
        <div>
           <asp:ScriptManager ID="ScriptManager1" runat="server">
           </asp:ScriptManager>
      
            <telerik:RadListBox 
                ID="RadListBox1" runat="server" OnTransferred="RadListBox2_Transferred" 
                AllowTransfer="true" EnableDragAndDrop="true" AutoPostBackOnTransfer="true"             
                TransferToID="RadListBox2">
                  
            </telerik:RadListBox>
              
            <telerik:RadListBox ID="RadListBox2" EnableDragAndDrop="true" AutoPostBackOnTransfer="true" runat="server">
                  
            </telerik:RadListBox>
      
            <asp:Label Text="" ID="Label1" runat="server" />
      
        </div>
        </form>
      
      
    Code Behind:
      
    protected void Page_Load(object sender, EventArgs e)
        {
             if (!this.IsPostBack)
              {
                RadListBox1.LoadContentFile("XMLFile.xml");
                RadListBox2.LoadContentFile("XMLFile.xml");
              
        }
        protected void RadListBox2_Transferred(object sender, RadListBoxTransferredEventArgs e)
        {
            try
            {
                Label1.Text = String.Empty;
                foreach (RadListBoxItem item in RadListBox1.Items)
                {
                    string text = item.Text;
                    Label1.Text += text + "; ";
                }
            }
            catch
            { }
        }
      
    XML Data file:
      
    <?xml version="1.0" encoding="utf-8" ?>
    <Items>
      <Item Text="Group1" Value ="100" />
      <Item Text="Group2" Value ="200" />
      <Item Text="Group3" Value ="300" />
      <Item Text="Group4" Value ="400" />
      <Item Text="Group5" Value ="500" />
      <Item Text="Group6" Value ="600" />
      <Item Text="Group7" Value ="700" />
    </Items>

     

  5. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 18 Dec 2012 Link to this post

    Hello Meng,

    This happens because the OnTransferred event is raised before the items are put in their respective order. This is a design decision and getting the correct order of the items in the OnTransferred event is not possible.
     
    Kind regards,
    Bozhidar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top