Get updated Kendo Tree View data source

lbrahim picture lbrahim · Sep 9, 2013 · Viewed 8.6k times · Source

I am showing the tree view with a datasource but after dragging and dropping there will be changes and I have to get that changed new datasource. How do I do that?

$.ajax({
         type: "POST",
         url: "TestMenu.aspx/GetMenuData",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function (data) {
         $("#treeview").kendoTreeView({
                 dragAndDrop: true,
                 dataSource: $.parseJSON(data.d)
             });
          }
         });

Answer

lbrahim picture lbrahim · Sep 10, 2013

So, I finally accomplished the task. Posting answer for anyone who's looking for the same answer as I was.
Changed the call to:

       $.ajax({
           type: "POST",
            url: "TestMenu.aspx/GetMenuData",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                $("#treeview").kendoTreeView({
                    dragAndDrop: true,
                    dataSource: $.parseJSON(data.d)
                }).data("kendoTreeView");
            }
        });

Then to get the updated data source:

var treeviewDataSource = $("#treeview").data("kendoTreeView").dataSource.view();