This is a migrated thread and some comments may be shown as answers.
1st Time Binding ObservableCollection to Root is lightning fast, 2nd time is awfully slow..
3 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 11 Feb 2011, 08:33 PM
1st Time Binding ObservableCollection to TreeView Root is lightning fast. But adding more records to an obserable collection after it's already bound is very, very slow.

Description:

I'm using the Virtualization.

We have multiple customers who put 50,000 records into the root of the treeview. We have our own framework that calls the server async and populates an observable collecion in the ViewModel with data.  Right now, it takes about 30-45 seconds to query data on the server-side.  That is our limitation, not yours.  Which means if I want to get 50,000 records then the client has to wait 30-45 seconds for the client side to request data, server to retrieve data, and client-side to populate the observable collection with data and bind to the treeview control.

My observations of this scenario:

When getting all 50,000 records at one time then your control loads within seconds (minus our 30-45 second query). It's very fast.

this
.FolderTreeView.ItemsSource = null
AddRootNodes(); //add root nodes to observable collection
this.FolderTreeView.ItemsSource = tv.TreeViewSource; //bind observable collection to treeview.

The above performs well

The problem is sending a huge amount of data all at one time. Instead, we want to break up the 50,000 records into 5,000 chucks. This means we would do 10 calls between the client and the server to fill the root of the tree.

Now, If I want to break up the 50,000 into 10 seperate calls between the client and server then performance becomes sluggish. The inital binding as I have shown above is very quick. I use the same approach with the first 5000 records returned from the server and placed into an observable collection. The looping to put the records into an observable collection happens within seconds. It's very quick to loop and bind. Very efficient.

Getting the next 5,000 record from the server is fast but loading those new 5,000 records into the the observable collection (which is bound to the treeview) is slow. So, slow that the UI locks up. It appears that since the observable collection is bound to the tree view that something is causing a bottle neck. I would think that the virtualization would not care about the new 5,000 records since they are not shown.

I'm not sure where the bottle neck is here. Any examples to eleviate the problem would be appreciated.

If you need to see the example then I can send it to you. I took one of your examples in a forumn and built upon it. Basically, I get root data and bind it to the tree. Then get more root data and put it into an observable collection that is already bound to the tree already. That's the point where things get very sluggish.

Thanks, -John

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 16 Feb 2011, 05:24 PM
Hi John,

Yes, any code would be highly appreciated since  you describe a more complex scenario and this way we could investigate in depth and provide you with a better suited solution faster. Thank you in advance.

Best wishes,
Petar Mladenov
the Telerik team
0
John
Top achievements
Rank 1
answered on 16 Feb 2011, 10:29 PM

How do I attach a zip file to this?
0
John
Top achievements
Rank 1
answered on 16 Feb 2011, 11:06 PM
I created a support ticket for this and attached the zip files...The telerik ticket ID is: 395194

Please reference the zipped up file in that support ticket.

Thanks, -John
Asked by
John
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
John
Top achievements
Rank 1
Share this question
or