Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating jstree jquery_ajax in controller
    primarykey
    data
    text
    <p>I am using MVC3, Jquery, and jstree, my goal is to display the jstree with the help of json_data from the controller, I have researched this as much as I could but have not solved it, my problem is how to relate the function(n/node) to the action in the controller, and how to send the node list that I create in the controller action back to the view and parse the data, I will greatly appreciate any help or advise.</p> <pre><code> &lt;script type="text/javascript"&gt; $(function () { $("#demo1").jstree({ "themes": { "theme": "default", "dots": true, "icons": false, "url": "/content/themes/default/style.css" }, "json_data": { "ajax": { "async": true, "url": "/Home/GetItems", "type": "POST", "data": function (n) { return { id: n.attr ? n.attr("id") : 0 } "dataType": "text json", "contentType": "application/json charset=utf-8", "progressive_render": true } } }, "plugins": ["themes", "json_data", "dnd"] }) }); </code></pre> <p>and here is my controller code with the GetItems():</p> <pre><code> [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetItems() { int cnt = 0; var itemRawData = (from ItemInfo itemtInfo in _itemInfoCollection where itemInfo.Name == "val1" || itemInfo.Name == "val2" select new itemSpecifications { itemName = itemInfo.Name, itemVersion = itemInfo.MajorRevision.ToString() + "." + itemInfo.MinorRevision.ToString(), iCount = ItemInfo.Count, ilist = itemInfo.Values.Cast&lt;subitem&gt;().ToList(), index = cnt++ }); TreeNode node = new TreeNode(); List&lt;TreeNode&gt; nodelist = new List&lt;TreeNode&gt;(); foreach (var t in itemRawData) { nodelist.Add(new TreeNode { data = String.Format("{0} {1} ({2})",t.itemName, t.itemVersion, t.iCount.ToString()), state = "closed", children = t.ilist }); } return Json(nodelist); } </code></pre> <p>any example or advise will be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    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.
    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