Destination listbox client side sorting

3 posts, 0 answers
  1. brian
    brian avatar
    23 posts
    Member since:
    Aug 2008

    Posted 20 Oct 2011 Link to this post

    Hi,

    I have list box control with transferable items working.
    I would like to see all items transferred to the right (destination) listbox to be automatically sorted by text of the item.

    So I attached JavaScript handler to "OnClientTransferred" client side event of the source listbox.

    This is portion of my code:

                        //Sorting items in the right list box -----------------------
                        var items = e.get_destinationListBox().get_items();                                                     
                        arrTexts = new Array();
     
                        for (var i = 0; i < items.get_count(); i++) {
                            arrTexts[i] = items.getItem(i).get_text();                     
                        }
     
                        arrTexts.sort();              
                                                     
                        for (var i = 0; i < arrTexts.length; i++) {
                            //alert(arrTexts[i]);                       
                        }

    As you see, I can get text values from destination listbox, put them into string array and sort that array. 
    I just need advise on how I can now sort the content of the destination listbox.

    Thanks!
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Oct 2011 Link to this post

    Hello Brian,

    As far as I know RadListBox doesn't supports client-side sorting. So one suggestion is to use the server-side sorting.
    You could sort the listboxes after items are transferred hook on the OnTransferred event of the listbox that you want to sort and use the following code:
     RadListBox1.Sort = RadListBoxSort.Ascending;
     RadListBox1.SortItems();


    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. brian
    brian avatar
    23 posts
    Member since:
    Aug 2008

    Posted 21 Oct 2011 Link to this post

    Thanks Shinu, that works for me. 
    For some reason I was convinced that there sorting possibility on the client side just like there is one for regular ASP.NET ListBox control.


Back to Top