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

Load User Control as a treeview node Ondemand

3 Answers 183 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Krishna
Top achievements
Rank 1
Krishna asked on 28 Dec 2015, 02:34 PM

Hi,

   I am using a RadTreeView for displaying certain data in our application.Lets say I need to display 20 records (5 types and 4 records per type. Example: 20 cities where 4 cities each are grouped to a state). In my application I can have upto 200-300 such records real time.

My Approach:

I am populating all the tree view during page load. So in theory, I am creating 20 instances of a user control and adding them to the treeview which is causing a huge performance issue.

 

What I need:

I need to populate only the parent nodes (5 states from above) and when expanded on a parent node, dynamically add 4 user controls to that node.

Please suggest if there is an example you have (Request to not share examples that just populates text from a data source. You can hard code the number 4 if that makes it easy) or provide an approach for me to execute.

 

Thanks in advance.

Regards,

Krishna Chaduvula.

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 31 Dec 2015, 11:36 AM
Hello Krishna,

You can use the TreeView's NodeExpand server-side event and load the user controls in its handler. This way you can improve the performance by loading them only for the expanded root node, not for all root nodes. 
I attached a sample website, which demonstrates this approach. The Telerik sample database the TreeView is bound to is included and Telerik .dll files have to be added to the project's bin folder.

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Krishna
Top achievements
Rank 1
answered on 04 Jan 2016, 09:22 AM

Thanks Ivan for the prompt response and the sample. I ran into an issue while executing your approach in my application. When I expand the tree node i get "Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors()". I did some research and found that the telerik controls that I am using in my user control are infact causing this issue. I have a RadDatePicker and a RadCombobox (OnDemand enabled to true). Can you please give this a shot and provide any solution for my issue?

 

Thanks in Advance.

Regards,

Krishna Chaduvula.

0
Ivan Danchev
Telerik team
answered on 07 Jan 2016, 08:13 AM
Hello Krishna,

The problem with using a RadComboBox or other controls that are loaded on demand is that if you are creating them dynamically this has to be done on every postback, otherwise when the server callback is performed the ComboBox will not be found. In your scenario the ComboBox is not created on every postback but when a node is expanded, so the ComboBox and other controls in the created dynamically UserControls must not be using the Load on Demand mechanism.

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Krishna
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Krishna
Top achievements
Rank 1
Share this question
or