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

Adding many items to RadListBox

1 Answer 191 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Dave Hollen
Top achievements
Rank 1
Dave Hollen asked on 11 Mar 2010, 08:13 PM
Hello,

I am trying to use a RadListBox to display items that a user has selected on a RadGrid.

There is an instance where, on a button click, I am attempting to add 2000+ items to the radlistbox.  This is all being done in JavaScript.

When adding this many items, the browers (IE 8) displays a message stating that there is script being run on the page that is causing the page to not respond.  I believe this is being caused by having to add so many items to the RadListBox.

Is there a workaround for this, or another control that i can use to display selected items from the grid?  I need to keep this on client side in Javascript.

Here is the script that I am using to add items to the RadListBox (my radlistbox is named rlbSelectedContacts):

                            var rlbSelectedContacts = $find("<%=rlbSelectedContacts.ClientID %>");
                            if (rlbSelectedContacts)
                            {
                                    for (each item in my list of items to add) //this FOR loop could iterate thousands of times
                                    {
                                        var item = new Telerik.Web.UI.RadListBoxItem();
                                        if (item)
                                        {
                                            item.set_text(contactName);
                                            item.set_value(contactId);
                                            rlbSelectedContacts.trackChanges();
                                            rlbSelectedContacts.get_items().add(item);
                                            rlbSelectedContacts.commitChanges();
                                         }
                                    }
                             }


1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 12 Mar 2010, 08:36 AM
Hello Dave Hollen,

It's expected behavior, because IE doesn't handle dom elements so good and you're adding too many items.
I recommend using RadComboBox instead and load the items on demand as it's demonstrated here.

Greetings,
Yana
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
ListBox
Asked by
Dave Hollen
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or