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

Use Drag and Drop to Rearrange Items and then Persist Order back to Database

8 Answers 306 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 14 Feb 2011, 05:39 AM
I am evaluating the Silverlight Controls to see how well they will work for my project. I have played around with the TreeView for awhile and am getting good results so far.

My next task is to use the Drag and Drop engine to allow the user to reorder items within the same tree. Once they are done reordering, I then want to persist the ordering back to the database. I am using a self-referencing hiearchy + RIA + Entity Framework, but that part shouldn't really matter for this scenario.

I imagine my workflow would be something like this:
1) Load my entities into an ObservableCollection, and bind that to the TreeView
2) Allow the user to rearrange items as they see fit via Drag and Drop
3) They hit "save" and at that time, I need to rip through the TreeView and update my entities with the current order of the items (a simple SortOrder property in the entity)
4) Save the updated entities back to the database

I have looked for an example of this scenario and have not been able to find one. Is there any chance someone has had success doing something like this? I am hoping to get some feedback before I spend a ton of time going this route. In the past, I tried updating the SortOrder data on the fly as the drag and drops were being done and ran into all sorts of problems (with the default TreeView). 

I am hoping that between the RadTreeView and temporarily decoupling the TreeView data from database persistence that I can make this scheme work.

8 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 16 Feb 2011, 04:40 PM
Hello Stephen,

I am very pleased to hear that you want to implement such scenario since I am working on similar project these days. Tomorrow, I will upload a blog post named "How to Synchronize RadTreeView`s Drag and Drop Operation with the DataBase ,Part one: Moving a child element from one parent to another". Basically, it uses the MVVM design pattern, WCF RIA services and ADO.Net Entity Data Model. It will show how to move an item from a parent to node to another node and how to reflect this change in the database immediately. The second part of this blog post sequence will be related to drag and drop reordering operation. It will show the example you are looking for: drag and drop an item within the same  collection and updating its SortId property immediately.
However, I think the first blog post that should be available this friday will give you a good starting point. I also attached the beta version of the project I will use. It uses the standard Northwind database . You can download it from here.
Thank you for your interest.

Greetings,
Petar Mladenov
the Telerik team
0
Stephen
Top achievements
Rank 1
answered on 22 Feb 2011, 02:56 AM
Petar,

Thanks for the example. It is a good example of multiple concepts. I look forward to your blog posts, especially the reordering within a tree.
0
Petar Mladenov
Telerik team
answered on 24 Feb 2011, 12:52 PM
Hello Stephen,

Thank you for your interest,  the post for reordering of items should be available in the middle of March due to more impressing tasks we are currently working on.
Regards,
Petar Mladenov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Petar Mladenov
Telerik team
answered on 24 Feb 2011, 12:52 PM
Hello Stephen,

Thank you for your interest,  the post for reordering of items should be available in the middle of March due to more impressing tasks we are currently working on.

Regards,
Petar Mladenov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
yjh
Top achievements
Rank 1
answered on 12 Aug 2011, 10:38 AM
Is there a link to "How to Synchronize RadTreeView`s Drag and Drop Operation with the DataBase ,Part one: Moving a child element from one parent to another" ?

0
Petar Mladenov
Telerik team
answered on 17 Aug 2011, 07:44 AM
Hello Yjh,

 Here is the link to the mentioned blog post. It is now located in the Silverlight Team section of the blogs.telerik.com.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
yjh
Top achievements
Rank 1
answered on 28 Aug 2011, 04:47 AM
Thank you.

But I can't using search to find it.

Is there Part II ?
0
Petar Mladenov
Telerik team
answered on 31 Aug 2011, 03:50 PM
Hi Yjh,

 Probably, you have to first navigate to the Silverlight Team blog page and then search. Currently, there is no second part in this blog post series. Thank you for your interest.

Greetings,
Petar Mladenov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
TreeView
Asked by
Stephen
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Stephen
Top achievements
Rank 1
yjh
Top achievements
Rank 1
Share this question
or