This is a migrated thread and some comments may be shown as answers.

GetItemByPath for subnodes

7 Answers 191 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 15 Jan 2009, 04:30 PM
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

7 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 20 Jan 2009, 10:09 AM
Can someone confirm if this is a bug please.
0
Serrin
Top achievements
Rank 1
answered on 20 Jan 2009, 07:37 PM
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?
0
Accepted
Tihomir Petkov
Telerik team
answered on 21 Jan 2009, 11:39 AM
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.
0
David
Top achievements
Rank 1
answered on 21 Jan 2009, 11:48 AM
Thanks Tihomir and Serrin, this helped solve the problem.
0
Serrin
Top achievements
Rank 1
answered on 21 Jan 2009, 01:52 PM
Yes, thank you very much Tihomir, I had no idea such a workaround existed!
0
Maria Im
Top achievements
Rank 1
answered on 27 Apr 2010, 11:54 PM
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.
0
Kiril Stanoev
Telerik team
answered on 30 Apr 2010, 11:40 AM
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.
Tags
TreeView
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Serrin
Top achievements
Rank 1
Tihomir Petkov
Telerik team
Maria Im
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or