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

Save TreeView

6 Answers 115 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Meerkat
Top achievements
Rank 1
Meerkat asked on 15 May 2010, 11:28 AM
Hello,
A year or so ago, I asked how to save a tree but I don't think anyone really knew at that time. As a consequence, I gave up and scrapped the Treeview as being too difficult and have had to use unsatisfactory alternatives ever since.

Unfortunately I now have a job where a treeview is the only option so I HAVE to work out how to save a tree.

RadTreeView is brilliant at allowing drag and drop, node editing/deleting and a host of other great features.

However all these things are useless if an exact copy of the changed tree cannot be saved between sessions.

I have searched everywhere I can think of for an idea of how to save but without success.

I don't care how it it done. I don't care if an XML file or a database is used, I don't care what web service is used. I just want to be able to save a RadTreeView.

Can anyone please point me in the right direction. . Surely someone MUST have done this before as I cannot believe I am the only person who has ever needed to save changes to the tree. 

An actual working example would be perfect, but failing that, any suggestions, links etc. would be extremely well received.

If noone at Telerik knows how to save a tree, or if it is only possible with an extremely high level of know how and effort,
then I am happy to accept that drag and drop was a nice idea but has no practical use and I can move on.

Many thanks in anticipation.

Pete.

6 Answers, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 18 May 2010, 08:18 AM
Hello Meerkat,

Saving and persistence of all controls is our future plans, but at the moment I can't give any promises. Really sorry for that. Till the moment of having this feature I can suggest you to not persist the Tree itself, but a model (ViewModel) of the tree that describe each item (is it expanded, filtered ...)  and you should bind the TreeViewItem properties to each model property accordingly. So once you load the model and bind the tree to these properties - the tree will looks the same.  So the actual saving will be just serializing a simple objects describing the tree structure.
Hope this helps you.

Regards,
Miro Miroslavov
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
Deepthi
Top achievements
Rank 1
answered on 27 Sep 2010, 09:04 PM
hi,

I am using RadTreeview control in my application. how can i dynamically add nodes to the treeview and edit them using a screen which appears on the node selection? Please let me know about this.

Thank you,
Deepthi Sree.
0
Petar Mladenov
Telerik team
answered on 30 Sep 2010, 11:49 AM
Hi Deepthi,

A possible way to dynamically add/delete/edit nodes of the RadTreeView is to add a RadContextMenu with three items(ContextMenuItems): "Add item", "Remove Item", "Edit Item".

The RadTreeView supports editing and the feature can be turned on using the IsEditable property. Also you can set an ItemEditTemplate to define what to be displayed when the RadTreeViewItem is in edit mode. I prepared a sample project illustrating this approach. Please take a look at it and let me know if it works for you.

You can also read our help articles about the Editing feature of the RadTreeView:
http://www.telerik.com/help/silverlight/radtreeview-feautres-treeviewitem-item-editing.html
and check out the demos( and their code) related to ItemEditing and Add/Remove/Disable of tree items:
http://demos.telerik.com/silverlight/#TreeView/NodeEditing
http://demos.telerik.com/silverlight/#TreeView/AddRemoveDisable

I hope this helps and do not hesitate to ask if you need further assistance.

Greetings,
Petar Mladenov
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
Deepthi
Top achievements
Rank 1
answered on 30 Sep 2010, 10:44 PM
Hi,

Thank you for your quick reply and for the demo code. My actual requirement is dynamically binding the nodes to radTreeView from the database in a heirachy. I am able to add the nodes in as level1 heirarchy but i need them to be added in proper parent-child heirachy same as my object in the database.

Thank you very much in advance for the help.

Thank you,
Deepthi Sree.
0
Petar Mladenov
Telerik team
answered on 05 Oct 2010, 10:34 PM
Hi Deepthi,

There are different approaches towards implementing your scenario. Bellow you can find some helpful links: 
1. Binding to RIA Services:

2. Binding to WCF Service
3. Binding to ADO.NET data service
 
Please take a look at the info and let us know if we can further assist you.


All the best,
Petar Mladenov
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
Radhika
Top achievements
Rank 1
answered on 14 Feb 2012, 08:52 AM
Hii,
You have to create Dynamically tree nodes.
I think this will help u:
First of all get the list of what u have to display in the tree.
Bind it to the treeview. 
Set the HierarchicalDataTemplate. In this bind the subnode.
for example:
I am using Section and Question Tables for Displaying Data in the treeView
my structure is: Section:=>SectionId, SectionName    Question:=> QuesitonID, SectionID, Quesiton

Now i get the list of section in the collecitonObject SectionList.

now i use below code:
<telerik:RadTreeView x:Name="treeView1" IsDragDropEnabled="True" Margin="0,0,410,0" ItemsSource="{Binding Path=SectionList, Mode=TwoWay}" >
                <telerik:RadTreeView.ItemTemplate>  
                        <telerik:HierarchicalDataTemplate x:Name="SectionTemplate1"
                                          ItemsSource="{Binding Path=Questions, Mode=TwoWay}" >
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding Path=SectionName}"/>
                        </StackPanel>
                            <telerik:HierarchicalDataTemplate.ItemTemplate>
                                <DataTemplate x:Name="QuestionTemplate">
                                <telerik:RadTreeViewItem Header="{Binding Path=Question1, Mode=TwoWay}">
                                        
 
                                    </telerik:RadTreeViewItem>
                                </DataTemplate>
                            </telerik:HierarchicalDataTemplate.ItemTemplate>
 
                        </telerik:HierarchicalDataTemplate>
                     
 
                </telerik:RadTreeView.ItemTemplate>
            </telerik:RadTreeView>

This is it this will work.
Tags
TreeView
Asked by
Meerkat
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Deepthi
Top achievements
Rank 1
Petar Mladenov
Telerik team
Radhika
Top achievements
Rank 1
Share this question
or