10 Answers, 1 is accepted
The Kendo MVC TreeView supports both binding to a model on the server and using remote binding. In order to persist the changes when using drag and drop, you could use the drop event to post the changes to the server and save them or save the current TreeView data when a button is clicked.Kind regards,
the Telerik team
Thank you for the reply. I was trying the remote binding but that's where I ran into the DataSource being of type Kendo.Mvc.UI.Fluent.ReadOnlyDataSourceBuilder.
I'll trying the "binding to a model" approach and let you know if that works.
I'm still not getting this to work successfully. I've ended up using a hybrid of the .BindTo to bind to the data and specify the TreeViewItemId that I then use on the client side Drop event to get dropPosition, source TreeViewItemId, and destination TreeViewItemId. My next step was to code for the various before/after/over dropPosition combinations and call that operation via AJAX until I figured out that after an element has been dropped once it loses it's TreeViewItemId.
Do you have a working example that shows TreeView drag and drop changes being sent back to the server for persisitence? At this point it doesn't matter if it's an MVC wrapper example or not.
After finding this response to a similar issue of data lost on drop, http://www.kendoui.com/forums/permalink/SIr9YTAMhEOcpkT3XmrxRQ, I have change how I'm getting the Id's and that is successful now.
So I guess my question is if the path I'm on is really the only way to do this? Or is there a better recommended approach?
Indeed, the attributes are currently not persisted and the Id should be found from the node item.
The approach is correct. A custom request should be sent to the server to persist the changes. Also, if the dropPosition is different than "over" then the actual new parent will be the destination item parent. I attached a sample project using the Northwind Employees table.
the Telerik team
Would it be possible to post an update that's in MVC 5?
The relevant code should be identical in MVC5. What problems do you encounter when you use the same view and controller in MVC5?Regards,
See What's Next in App Development. Register for TelerikNEXT.
I was actually trying to run the code as is and, after updating the asp.net to 4.5.1 and system.web.mvc to 5, and webpages.version to 3.0.0 in the web.config, I get the following error:
I'm able to get the code working in a different project so not a big deal, but it would be helpful if the solution you provide were runnable as is. I'm finding the documentation on the MVC TreeView to be fairly thin.