IsExpanded w/ IsLoadOnDemandEnabled=true not working

4 posts, 0 answers
  1. Rob
    Rob avatar
    11 posts
    Member since:
    Jul 2008

    Posted 23 Jul 2008 Link to this post

    If I call ExpandAll() on a RadTreeViewItem that has LoadOnDemand enabled, the control will fire the LoadOnDemand event for that item. On the other hand, if I set IsExpanded=true on that same item, the LoadOnDemand event does not fire. Is this contradictory behavior intentional? Should I assume that the event will not be fired in the release version or is this a bug that will be fixed?

    Thanks
    Rob
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 24 Jul 2008 Link to this post

    Hello Rob,

    the LoadOnDemand event is raised only once - or until the items is empty. Once the item is populated the event is not fired. After the item is populated you can listen to the PreviewExpand event.

    This is behaviour by design. Let me know if you have any comments on that.

    Regards,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Rob
    Rob avatar
    11 posts
    Member since:
    Jul 2008

    Posted 24 Jul 2008 Link to this post

    Hi Valentin,

    The fact that LoadOnDemand is raised only once is not my problem.

    My problem is that if I set item.IsExpanded=true on a tree view item that has never fired LoadOnDemand, I would expect that item to fire LoadOnDemand, but it does not.

    If I change my code to replace the IsEnabled line with item.ExpandAll(), then the item does fire the LoadOnDemand event. I would expect IsExpanded and ExpandAll() to behave similarly in this respect since both actions cause the corresponding tree view node to be expanded.

    Do I have a correct understanding of what these 2 things do? It seems that setting IsExpanded=true is equivalent to clicking on the expand arrow of an unexpanded tree node therefor it should behave in a manner consistent with what occurs when the user does that, namely fire LoadOnDemand if appropriate.

    I am attempting to save the state of a tree and then refresh the tree's contents by clearing all the tree's items, reloading the tree, and re-expanding all nodes that were expanded prior to clearing the items. That is why I need to be able to programmatically expand a LoadOnDemand node? How do I accomplish that?

    Thanks
    Rob
  4. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 24 Jul 2008 Link to this post

    Hi Rob,

    Yes - the LoadOnDemand event should be fired with the node is expanded from IsExpanded property and from ExpandAll method.

    I just double checked that the LoadOnDemand event is fired when the IsExpanded property is set to true and when the node is expanded from the ExpandAll() method. I checked that with the latest version that we just released - can you please download it and give it a try.

    For your scenario you should work with the ItemContainerGenerator class and to expand the nodes once their parent is generated. Otherwise you will not have an access to the nodes - because of the UI vitualization.

    An overview about how to work with the ItemContainerGenerator is available on this online demo:

    http://www.telerik.com/demos/Silverlight/#Examples/TreeView/AccessingItems


    Sincerely yours,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top