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

Destination listbox client side sorting

2 Answers 230 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
brian
Top achievements
Rank 1
brian asked on 20 Oct 2011, 08:18 PM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Oct 2011, 12:37 PM
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.
0
brian
Top achievements
Rank 1
answered on 21 Oct 2011, 09:29 PM
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.


Tags
ListBox
Asked by
brian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
brian
Top achievements
Rank 1
Share this question
or