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

TreeView Master/Details Scenario example

4 Answers 79 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alexey Oyun
Top achievements
Rank 1
Alexey Oyun asked on 23 Jun 2010, 10:18 AM
  Hi, could you post an example of Master/Details Scenario with treeview through DataContext binding.

  For simplicity we will have treeview with persons. Next to it two text boxes with name and surname in stackpanel that has bindning to selected item. And button save changes.
  I need to save person data and reflect it in treeview. 
  I am using ObservableCollection for items, but changes to the item do not reflect in treeview.

4 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 25 Jun 2010, 05:20 PM
Hello Alexey Oyun,

I prepared a sample project illustrating hot to implement the described scenario. Please note that the Client data class that implements INotifyProperyChanged thus applying the changes made to the names through the textBoxes thus changing the data collection of the RadTreeView. Also, keep in mind that the changes will be reflected in the business object only if the TextBox's Text property is data bound in a TwoWay binding mode.

Take a look at the project and let me know if this is what you had in mind.

Regards,
Tina Stancheva
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
0
Alexey Oyun
Top achievements
Rank 1
answered on 28 Jun 2010, 01:48 PM
  Yes this is pretty much what I wanted.
  One question, how did you trigger save. In code I could not find any reference (Event or Command bindning) to Save button.
  Or is it default action for the button that in control bound to ObservableCollection item?
0
Tina Stancheva
Telerik team
answered on 28 Jun 2010, 06:25 PM
Hello Alexey Oyun,

Actually in the example, I haven't implemented any logic behind the Save button, since I wasn't sure if you have specific requirements for it.

However, since the TextBoxes are bound in a TwoWay mode and the Client class implements INotifyPropertyChanged, any changes made to the Name and LastName through the TextBoxes, are reflected on the original data source, which in this case is the Clients observable collection. And since the ObservableCollection implements INotifyCollectionChanged, any changes in it are applied to the ItemsSource collection of the tree.

Therefore if this logic satisfies the requirements of your scenario, a Save button won't be neccessary. Still, if the Clients collection needs to be further saved, you can implement custom logic using a Save button.

I hope this information will help you. Also, if you need more, please let us know.

Best wishes,
Tina Stancheva
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
0
Alexey Oyun
Top achievements
Rank 1
answered on 29 Jun 2010, 08:48 AM
Thank you Tina, I just figured out.
If I change last name and than select name textbox changes propagate to treeview through bindning.
But if I change lastname and than click to another node, changes won't propagate to treeview.
So if I want to change only last name I should click somewhere it the form to apply changes. Otherwise they are going to be lost. Or subscribe to textchanged event.

Well this is another story, so lets close this thread.

Once again, thanks Tina.

Sincerely, Alexey


Tags
TreeView
Asked by
Alexey Oyun
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Alexey Oyun
Top achievements
Rank 1
Share this question
or