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

9 posts, 0 answers
  1. Stephen
    Stephen avatar
    5 posts
    Member since:
    Feb 2011

    Posted 13 Feb 2011 Link to this post

    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.
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 Feb 2011 Link to this post

    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
  3. DevCraft banner
  4. Stephen
    Stephen avatar
    5 posts
    Member since:
    Feb 2011

    Posted 21 Feb 2011 Link to this post

    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.
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 24 Feb 2011 Link to this post

    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!
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 24 Feb 2011 Link to this post

    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!
  7. yjh
    yjh avatar
    67 posts
    Member since:
    Aug 2007

    Posted 12 Aug 2011 Link to this post

    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" ?

  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 17 Aug 2011 Link to this post

    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 >>

  9. yjh
    yjh avatar
    67 posts
    Member since:
    Aug 2007

    Posted 27 Aug 2011 Link to this post

    Thank you.

    But I can't using search to find it.

    Is there Part II ?
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 31 Aug 2011 Link to this post

    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 >>

Back to Top
DevCraft banner