Thanks,
Kyle
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,Daniel
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.
Thanks,
Kyle

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.
Thanks,
Kyle

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?
Thanks,
Kyle
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.
Daniel
the Telerik team

Would it be possible to post an update that's in MVC 5?
Thanks!
Laurie
Hello Laurie,
The relevant code should be identical in MVC5. What problems do you encounter when you use the same view and controller in MVC5?
Regards,Alex Gyoshev
Telerik
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:
[A]System.Web.WebPages.Razor.Configuration.HostSection <
br
>cannot be cast to <
br
>[B]System.Web.WebPages.Razor.Configuration.HostSection. Type A <
br
>originates from 'System.Web.WebPages.Razor, Version=1.0.0.0, <
br
>Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context <
br
>'Default' at location <
br
>'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.<
br
> Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, <
br
>Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context <
br
>'Default' at location 'C:\Users\cffmuser\AppData\Local\Temp\Temporary <
br
>ASP.NET <
br
>Files\vs\c257a789\13394f7e\assembly\dl3\267cafe6\be4dc955_fc75d001\System.Web.WebPages.Razor.dll'.
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.
Thanks.
Laurie
Hello Laurie,
This error can be resolved if you follow the MVC4 to MVC5 upgrade guide, and is not related to the TreeView functionality shown in the project.
Regards,Alex Gyoshev
Telerik
See What's Next in App Development. Register for TelerikNEXT.
