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

Adding/Removing Items from a databound tree - nothing selected.

1 Answer 70 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ciaran
Top achievements
Rank 1
Ciaran asked on 15 Sep 2009, 01:54 PM
I'm creating a databound tree structure. You click on an item in the tree to view its details.
My collection is an ObservableCollection of Items that implement INotifyPropertyChanged.

I use ContainerBindings to bind the selected Item to a ViewModel. When I select a new node in the tree I get the previous ViewModel's IsSelected property is set to false and the new one to true. All is good so far.

But I want to add/move/delete items from the tree.
I can do this by just add/move/delete to/from the ObservableCollection.

But users may expect:

1. When deleting a node

If the node has a next sibling select it.
If not, if it has a previous sibling select it.
If neither select the parent

2. When adding/moving a node

Select it

None of this behaviour is built in to the trees default behaviour. If you delete an Item from a Collection the tree does not deselect it and select the appropriate node. The MS treeview at least selects the parent.

I know this could be done on the ViewModel side by creating Next/PreviousSibling properties, populating them and then deselecting/selecting appropriately. But that is something that would have to be implemented for every collection and it gets complicated if the nodes are sorted.

Is this possible from the treeview itself?

1 Answer, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 16 Sep 2009, 06:05 AM
Hi Ciaran,

Thank you for your feedback. Yes this is possible and we can add such option for a future release of the treeview. I logged the issue and updated your Telerik points

Regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Ciaran
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Share this question
or