Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As my question explains, I have 3 steps:</p> <ol> <li>Server-bind the default tree</li> <li>Edit nodes (delete, add, rename nodes)</li> <li>Fetch back all treeview data (including added ones)</li> </ol> <p>After going through the <a href="http://docs.kendoui.com/api/web/treeview" rel="nofollow">kendo docs</a> and <a href="http://demos.kendoui.com/web/treeview/mvvm.html" rel="nofollow">this demo</a>, I got the point. I have to make my tree datasource observable so as to reflect the node-changes. For this I had to use kendo-web-scripts (instead of server wrappers). So I changed my step 1 to:</p> <ol> <li>Remote bind the default tree (To make my dataSource observable)</li> </ol> <p>I want my tree view fully loaded at once remotely and seeing this <a href="http://demos.kendoui.com/web/treeview/remote-data.html" rel="nofollow">demo</a>, I figured out that treeview only allows one level to be loaded at a time. (<a href="http://feedback.kendoui.com/forums/127393-kendo-ui-feedback/suggestions/3072947-treeview-allow-hierarchicaldatasource-to-be-fully-" rel="nofollow">UserVoice</a> already queued but Kendo team still ignoring it). So I use a hacky way:</p> <pre><code>&lt;div id="PipelineStructureMajor"&gt;&lt;/div&gt; &lt;button id="createandorinsert" class="k-button hugebtn"&gt;Send&lt;/button&gt; &lt;script&gt; $.get("../Structure/LoadTreeData", function (data) { var sat = new kendo.data.HierarchicalDataSource({ data: data }); var pipelinetree = $("#PipelineStructureMajor").kendoTreeView({ dataSource: kendo.observableHierarchy(sat), dragDrop: true, select: onNodeSelect }).data("kendoTreeView"); }); &lt;/script&gt; </code></pre> <p>And I sent my data to the controller action like:</p> <pre><code>$('#createandorinsert').click(function (e) { //TreeView's current datasource var tree = $("#PipelineStructureMajor").data("kendoTreeView").dataSource.data(); $.ajax({ url: '../Structure/FtpCreateAndOrSync', type: 'POST', data: { xmlNodes: JSON.stringify(tree) }, beforeSend: function (xhr) { alertSpan.removeClass().addClass("loading"); }, success: function (result, status, xhr) { alertSpan.removeClass().addClass("success"); }, error: function (jqXhr, textStatus, errorThrown) { alertSpan.removeClass().addClass("error"); } }); </code></pre> <p>});</p> <p>And on the controller side, I Deserialized string json as: Just showing partial code</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult FtpCreateAndOrSync(string xmlNodes) { //Deserializing nodes var xmlNodesModels = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize&lt;IEnumerable&lt;XmlNode&gt;&gt;( xmlNodes).ToArray(); ////Alternative //var data = JsonConvert.DeserializeObject&lt;IEnumerable&lt;XmlNode&gt;&gt;(xmlNodes); return Json(new { cr = createResult, dr = dbResult }); } </code></pre> <p>Hope this helps someone.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload