RadTreeView default IsExpanded not working in combination with LoadOnDemand in combination with IsVirtualized

6 posts, 1 answers
  1. Kristof Van Cauwenberghe
    Kristof Van Cauwenberghe avatar
    9 posts
    Member since:
    Apr 2010

    Posted 08 Jun Link to this post

    We have been using the RadTreeView with IsVirtualizing=False and IsLoadOnDemand=False for several years now.

    In the creation of RadTreeViewItems we specify if the node should be expanded or not. (Depending on the current user, the node is expanded).

     

    But because some clients are getting very large trees, we are looking for a solution to speed up the tree.

    I found the telerik example "TreeViewPerformance", and I managed to get it working in our application. With a very nice speed improvement.

    The only issue is that the IsExpand property does not work.

    I create a new RadTreeViewItem. And I set following ".IsExpanded = bIsExpanded".

     

    I found a workaround for this. In the "Loaded" event, to set this property again.

    With this enabled, the tree expands as expected.

     

    Is this a bug that the expand does not work as it does when not using virtualisation and loadondemand?

    Or how can I solve this without the extra event.

    Attachment contains the UserControl with example that shows the problem.

     

    I'm using the latest dll's. Silverlight_2016_Q2\2016_2_503\

  2. Kristof Van Cauwenberghe
    Kristof Van Cauwenberghe avatar
    9 posts
    Member since:
    Apr 2010

    Posted 08 Jun Link to this post

    Attachment: https://www.dropbox.com/s/x8d7ti6aio4gx0p/SilverlightTreeViewPerformance.zip?dl=0
  3. DevCraft banner
  4. Answer
    Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 09 Jun Link to this post

    Hello Kristof Van Cauwenberghe,

    The described behavior is expected. Basically, there is nothing to expand because the nodes still not have its Items collection populate. That is why the nodes are not expanded. You can populate the tree view items in the GetNextTreeItem() method so you can observe the describe behavior.
    for (int i = 0; i < 5; i++)
    {
        oItem.Items.Add(new RadTreeViewItem() { Header= GetNextNodeName()});
    }
    You can take a look at the Load On Demand help article in our documentation. 

    After I have examined your project I noticed that you're populating the RadTreeView with RadTreeViewItems. However, when using the UIVirtualization feature of the control, it's important to note that it is designed to work within a data-bound RadTreeView. This means that it will only work correctly, if the RadTreeView.ItemsSource collection is populated with business items. You can read more about the virtualization in the RadTreeView in the UI Virtualization help article in our documentation.
    Regards,
    Dinko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  5. Kristof Van Cauwenberghe
    Kristof Van Cauwenberghe avatar
    9 posts
    Member since:
    Apr 2010

    Posted 09 Jun in reply to Dinko Link to this post

    Hi,

    We know we should refactor our code to work with a data-bound collection. But before we do that, I would like to know following.

    Lets take the TreeViewPerformance example (http://demos.telerik.com/silverlight/#TreeView/Performance)

     

    Is it possible, with virtualization enabled, to expand to a specific node.

    For example that on load, following automatically expands "Secret Team\Fixes Team\Environent Group"

    We used to set the RadTreeViewItems to IsExpanded=true. But how can we do this when a collection is bound.

     

  6. Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 14 Jun Link to this post

    Hello Kristof Van Cauwenberghe,

    You can create a boolean property in your business object and bind it to the IsExpanded property of the RadTreeViewItems via style. We have Binding the IsExpanded property section in our help documentation where this approach is further described. 

    Let us know if this works for you or you have any other questions.

    Regards,
    Dinko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  7. Kristof Van Cauwenberghe
    Kristof Van Cauwenberghe avatar
    9 posts
    Member since:
    Apr 2010

    Posted 16 Jun in reply to Dinko Link to this post

    Hi,

    I managed to get our tree fully working via a data-bound collection.

    At this moment I do not have any issues. So this case can be closed.

    Thanks

Back to Top
DevCraft banner