<script type="text/javascript" class="source below"> $(document).ready(function () { $('#fvNavTree').jstree({ 'core': { 'data': { "dataType": "json", 'url': '/FileVault/getnavdata1', 'data': function (node) { return { 'id': node.id }; } } }, "plugins": ["contextmenu", "sort"] })
.delegate("a", "click", function (event, data) { event.preventDefault(); }); }); </script>
var nodeidlist = ["N_-1_5721", "N_1553_5721","N_10145_5721","N_10146_5721","N_20145_5721"]; $('#fvNavTree').jstree(true)._load_nodes(nodeidlist,function (e, data){}, false );
However, the returned JSON string for each node id in the array is not being inserted into the jstree
when using the lode_nodes call. I can verify this by looking at the html of the page.
After researching this a lot it I cant help but again think it has to somehow be related to the parent
node maybe not existing yet depending on the order in the array. Without the parent id for each node how
does it even know who the parent is unless it assumed it by the order of the array.
So Next I thought to add the 'parent' field for each node to the JSON string itself.
(see the new json string in #3 sample below) but when I do this the javascript throws exception
var tid = d.id.toString(), because d is undefined, line 1514 of jstree.js in _append_json_data : function (dom, data, cb, force_processing) {
You have any ideas?
Thanks,
Chris
#1) Root of the tree (before I added 'parent' to the json){"ContentEncoding":null,"ContentType":null,"Data":[{"children":false,"id":"N_10152_5721","text":"2014","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":false,"id":"N_10153_5721","text":"2015","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":true,"id":"N_1553_5721","text":"Receipts","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":false,"id":"N_10150_5721","text":"Test Folder 1","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":false,"id":"N_10151_5721","text":"Test Folder 2","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}}],"JsonRequestBehavior":0,"MaxJsonLength":null,"RecursionLimit":null}#2) Node for expansion of a node called My Documents (before I added parent){"ContentEncoding":null,"ContentType":null,"Data":[{"children":true,"id":"N_10145_5721","text":"2014","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}}],"JsonRequestBehavior":0,"MaxJsonLength":null,"RecursionLimit":null}
#3) Root after I add 'parent' id to the json{"ContentEncoding":null,"ContentType":null,"Data":{"children":[{"children":true,"id":"N_-1_5721","parent":"N_-11_0","text":"My Documents","state":{"opened":false,"disabled":false,"selected":true},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":true,"id":"N_-4_0","parent":"N_-11_0","text":"Client User Documents","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":true,"id":"N_-5_0","parent":"N_-11_0","text":"Firm User Documents","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":false,"id":"N_-2_0","parent":"N_-11_0","text":"Private Firm Documents","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},{"children":false,"id":"N_-3_0","parent":"N_-11_0","text":"Public Documents","state":{"opened":false,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}}],"id":"N_-11_0","parent":"#","text":"Secure File Vault","state":{"opened":true,"disabled":false,"selected":false},"a_attr":{"class":null},"li_attr":{"class":null}},"JsonRequestBehavior":0,"MaxJsonLength":null,"RecursionLimit":null}