Load User Control as a treeview node Ondemand

4 posts, 0 answers
  1. Krishna
    Krishna avatar
    2 posts
    Member since:
    Mar 2009

    Posted 28 Dec 2015 Link to this post

    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.

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    831 posts

    Posted 31 Dec 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Krishna
    Krishna avatar
    2 posts
    Member since:
    Mar 2009

    Posted 04 Jan in reply to Ivan Danchev Link to this post

    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.

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    831 posts

    Posted 07 Jan Link to this post

    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
Back to Top