Loading controls when tab is active

3 posts, 0 answers
  1. John
    John avatar
    34 posts
    Member since:
    Oct 2010

    Posted 30 Mar 2011 Link to this post

    In one of my pages, I have a tab control which has 5 tabs.  Each tab has several gridviews.   It takes up to 2 minutes for all controls to be bound (all data is loaded).  The performance is not acceptable in this case.

    My question is:  Is there a way to load only controls in an active tab?  Others are not until the tab is selected?

  2. Stas
    Stas avatar
    11 posts
    Member since:
    Aug 2010

    Posted 01 Apr 2011 Link to this post

    First, you can load data in a background thread and display busy indicator during the load,
    2ndly you can put content of a tab into  a separate control and subscribe to its Loaded event and load data in the handler.
    3rd, you can subscribe to TabControl.SelectionChanged (PreviewSelectionChanged) events and load data in the handler..
    But things become a little harder if you need logic to prevent from navigating to other tabs if current one has errors.
  3. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 04 Apr 2011 Link to this post

    Hello John,

    By default the RadTabControl creates only one ContentPresenter for the currently selected TabItem and uses it to display the content of this TabItem.

    Then when you select another RadTabItem, its content is rendered in the same ContentPresenter and therefore the content of the previously selected item is removed from the visual tree.

    However, I am not sure what is taking so much time to load in your case. Is the RadTabControl databound to a business collection. If it is, then perhaps you can optimize the load of the data - load only what you need to display in the selected RadTabItem since the control won't create the content of each RadTabItem on load - only the selected content will be loaded.

    Also Stas's suggestions can further help you optimize the performance of the control. If this information doesn't help or we are missing something, please elaborate on your scenario a bit more. If you can send us a sample project we will gladly look into the performance of the control in your case.

    Kind regards,
    Tina Stancheva
    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
Back to Top