GetItemByPath for subnodes

8 posts, 1 answers
  1. David
    David avatar
    4 posts
    Member since:
    Dec 2008

    Posted 15 Jan 2009 Link to this post

    Hi,

    Using GetItemByPath to search for subnodes will only work if the user has expanded the nodes first. I also tried to recursively get the root node and expand programatically to the subnode, but I still get null returned.

    I have also tried ContainerFromItemRecursive and this also returns null.

    Is there some workaround I can try to select the searched for node?

    Thanks

    David
  2. David
    David avatar
    4 posts
    Member since:
    Dec 2008

    Posted 20 Jan 2009 Link to this post

    Can someone confirm if this is a bug please.
  3. DevCraft banner
  4. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 20 Jan 2009 Link to this post

    Hey David,

    I'm guessing the answer will be similar to the one in this WPF post:

    http://www.telerik.com/community/forums/wpf/treeview/binding-to-checkstate.aspx#722022

    If the treeview hasn't been expanded, then there's no item to search for...  Or at least, I'm assuming the same logic carries from WPF to Silverlight.

    So, that leads me to wonder, anybody out there found a workaround to this issue?
  5. Answer
    Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 21 Jan 2009 Link to this post

    Hello David,

    As Serrin suggested, your issue is similar to the one described in this post:

    http://www.telerik.com/community/forums/wpf/treeview/binding-to-checkstate.aspx#722022

    Before the items are displayed i.e. their parent is expanded, they are not generated. So, if you need to select a child node programatically, you'll have to first expand the parent node and listen for the ItemContainerGenerator.StatusChanged event. In the event handler you should check if the status is "ContainersGenerated" and then select the node you want. Before the ItemContainerGenerator status becomes "ContainersGenerated" you won't be able to select the child node. Let me know if this solves your issue.

    Regards,
    Tihomir Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. David
    David avatar
    4 posts
    Member since:
    Dec 2008

    Posted 21 Jan 2009 Link to this post

    Thanks Tihomir and Serrin, this helped solve the problem.
  7. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 21 Jan 2009 Link to this post

    Yes, thank you very much Tihomir, I had no idea such a workaround existed!
  8. Maria Im
    Maria Im avatar
    10 posts
    Member since:
    Sep 2012

    Posted 27 Apr 2010 Link to this post

    I am using MVVM with the treeview and it's on Load on demand(so very difficult). Initially, it all loads by displaying documents only. Now let's say I end up selecting 4.Image Picture(thats like 3 levels down from Treatment), how do I save that path when i move to another view and then come back to the view where the treeview is and I am still at the Selected item.

    Whenever a view closes, It refreshes the TreevIew, therefore all collapses, which i dont want. ItemContainerGenerator doesnt help either.

    When I select an Item on the view for example
    1.Treatment
        2Visit Date
            3Documents
            3Images
                    4. Image Picture
            4.Freehandnotes
    1.Treatment
        2.VisitDate
            3Documents
                    4. Doc Image
            etc...
            etc...

    Please help.
  9. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 30 Apr 2010 Link to this post

    Hi Maria,

    You will manually have to save the path to the selected item. I'm attaching a sample project that demonstrates one possible solution to this scenario. Have a look at it and let me know if it helps. I'd be glad to further assist you.

    Greetings,
    Kiril Stanoev
    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
DevCraft banner