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

How can I improve the performance of add items with client side?

13 Answers 170 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Winson qiu
Top achievements
Rank 1
Winson qiu asked on 30 Sep 2009, 04:21 AM
I would like to add about 10000 recoders to a RadListBox in client side, I used the follows code:

var getCallBack = function(returnValue) { 
                items = returnValue.value; 
                if (items != null && items != "") { 
                    var rows = items.Tables[0].Rows, i = 0, l = rows.length;                     
                    for (; i < l; i++) { 
                        //add new items 
                        var raditem = new Telerik.Web.UI.RadListBoxItem(); 
                        raditem.set_text(items.Tables[0].Rows[i].Description); 
                        raditem.set_value(items.Tables[0].Rows[i].Code); 
                        oRadListItems.add(raditem); 
                    } 
                } 
            } 

it will be very slow when large items (about 10000 records) , and the browser will be halts.

if I use html control (select), I can use array to do this, then it will be very fast , just like
for (; i < l; i++) { 
            k.push("<option value='" + items.Tables[0].Rows[i].Code + "'>" +  items.Tables[0].Rows[i].Description + "</option>"); 
        } 

so I don't know whether can I improve the performance of RadListBox, have any idea to solve this ?

thank you !



13 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 30 Sep 2009, 08:48 AM
Hi Winson qiu,

You can use the newly added insertItems method of the RadListBox. It serves for bulk insert of items and will dramatically reduce the load time. Unfortunately, the method is having problems  under IE, it takes about 18 seconds to insert 10000 items. We have looked into that issue and it is already fixed. You can find the fixed version in the tomorrow's internal build. More information on how to obtain the latest internal can be found here.

For your convenience I have attached sample project that reproduces the bulk insert approach. The sample adds 10000 items in one operation.

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Winson qiu
Top achievements
Rank 1
answered on 30 Sep 2009, 02:51 PM
Thank you so much!!
0
Winson qiu
Top achievements
Rank 1
answered on 05 Oct 2009, 02:13 AM
I have tried the new method, it really faster then before, but when I try to add 10000 item , it still slow , it taks about 2 minute to finished, and you said it takes 18 seconds for this , have any mistakes in my code ?

function Test() { 
                var listBox = $find("RadListBox1"); 
                var oListItems = listBox.get_items(); 
                var arr = []; 
                var s = ""
                var d = new Date(); 
                s += "\n\r start time is: "
                s += d.getMinutes() + ":"
                s += d.getSeconds(); 
                //oListItems.clear(); 
                for (var i = 0; i < 10000; i++) { 
                    var item = new Telerik.Web.UI.RadListBoxItem(); 
                    item.set_text("text" + i); 
                    item.set_value("text" + i); 
                    arr[i] = item; 
                    //oListItems.add(item); 
                } 
                listBox.insertItems(arr); 
                 
                d = new Date(); 
                s += "\n\r end time is: "
                s += d.getMinutes() + ":"
                s += d.getSeconds(); 
                alert(s); 
            }   

the result is :
start time is: 3:13
end time is: 5:33

thanks!



0
Genady Sergeev
Telerik team
answered on 07 Oct 2009, 09:07 AM
Hi Winson qiu,

The time that goes for the insertion of 10 000 items strongly depends on the speed of the computer you are testing on. If you run it on a slower machine you will get higher execution time.

We have done some additional improvements on the insertItems method.Now it should work even faster than before. You can verify it on the latest internal build. More information on how to obtain the latest internal can be found here. Please, give it a try.

Greetings,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Winson qiu
Top achievements
Rank 1
answered on 07 Oct 2009, 09:11 AM
Oh, I see, thank you !
0
Ajay Gandhi
Top achievements
Rank 1
answered on 20 Apr 2010, 09:20 PM
I am binding the RadListBox on the serverside with a dataset that gets data from the database. There are about 2000 rows. It takes about 8 secs to load. Could you please help?

I tried using the built-in listbox web control and it takes 3 secs to load.
0
Genady Sergeev
Telerik team
answered on 21 Apr 2010, 05:44 PM
Hello Ajay Gandhi,

We are aware of that issue and have already worked on improving RadListBox performance. The fix is going to be available together with the next internal build. More information on how to obtain the latest internal build can be found here.

Sincerely yours,
Genady Sergeev
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.
0
Ajay Gandhi
Top achievements
Rank 1
answered on 21 Apr 2010, 09:14 PM
Thank you for the quick response. I see a build 2010.1. Is the fix available in this build?
0
Genady Sergeev
Telerik team
answered on 22 Apr 2010, 08:36 AM
Hi Ajay Gandhi,

The build is going to be available later today or tomorrow at latest.

Greetings,
Genady Sergeev
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.
0
Ajay Gandhi
Top achievements
Rank 1
answered on 28 Apr 2010, 07:45 PM
Is the build available now?
0
Yana
Telerik team
answered on 29 Apr 2010, 09:05 AM
Hi Ajay Gandhi,

Yes, please download the latest internal build from your Client.Net account.

Kind regards,
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.
0
Ajay Gandhi
Top achievements
Rank 1
answered on 29 Apr 2010, 07:17 PM
Questions:

1. There is only one internal build '2010.1'. When I read the things that got fixed in this build there is no mention of the problem that I am facing. Are you guys sure this is the fix I am suppose to download?

2. If yes, how do we apply the fix on our systems?

3. What is client .NET account?

4. It clearly mentions that you guys have not tested  the build in QA and do not support it. What does that mean?

0
Yana
Telerik team
answered on 04 May 2010, 11:14 AM
Hello Ajay Gandhi,

Straight to the questions:

1. May be your fix is included in the previously uploaded build, but it will be available also in the current one, so download it and give it a try.

2. You can use either the installer or the hotfix package containing the dlls, this article might be of help.

3. Client.Net account is actually your account on the Telerik site.

4. Please check this blog post about this question.

Kind regards,
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
Winson qiu
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Winson qiu
Top achievements
Rank 1
Ajay Gandhi
Top achievements
Rank 1
Yana
Telerik team
Share this question
or