jstree

jstree get the level of selected node

荒凉一梦 提交于 2019-12-12 12:14:35
问题 How can I get the degree/level of the currently selected node? I.e. the number of parents it has. I have the section which executes on selection of a node as such: .bind("select_node.jstree", function (event, data) { var nodeInfo = $("#" + data.rslt.obj.attr("id")); console.log(data.rslt.obj.attr("id")); // the id of the node console.log(nodeInfo.children("a").text()); // the name of the node // the level of the node??? }); 回答1: data.inst.get_path().length 1 is root node; .bind("select_node

Replacing a jstree node on ajax call

放肆的年华 提交于 2019-12-12 11:51:10
问题 I have a jstree object that I use for storing data, and I use ajax to complete it step after step. I call an ajax.php file that will return nodes formatted in HTML, depending on the data I send to it. My problem is the following: I know the data I will receive already contains the structure of the current node, and instead of replacing the current node with the data it receives from the ajax call, the jstree adds the structure to the current nodes as a new son, which is not what I want. For

Having a jsTree with checkboxes, how can i disable all checkboxes?

六月ゝ 毕业季﹏ 提交于 2019-12-12 11:28:18
问题 I have a jsTree, built dynamically, that allows the user to select whatever nodes he chooses. Now i'm trying to make this tree readonly so that other users can see the information without altering it. All examples i find are about disabling a specific node... My question is: Is there a way to define all the checkboxes on the tree to readonly? Code being used: jQuery.noConflict(); jQuery( function() { jQuery("#divTree").jstree( { "plugins": ["themes", "json_data", "checkbox", "sort", "ui",

jsTree Object has no method addBack

扶醉桌前 提交于 2019-12-12 11:23:17
问题 This is my instantiation code for the jsTree. $("#folder_tree").jstree({ "themes" : { "theme" : "default", "dots" : true, "icons" : true }, "json_data" : { "ajax" : { "url" : "/portal/folders", "data" : function(n) { if ($(n[0]).find("a").attr("id")) { console.log($(n[0]).find("a").attr("id").split('_')[1]); return { "id" : $(n[0]).find("a").attr("id").split('_')[1] }; } return { "id" : "0" }; } } }, "plugins" : [ "themes", "json_data", "ui", "contextmenu", "dnd", "search", "crrm" ] }).bind(

Can I display/create jsTree on button click?

笑着哭i 提交于 2019-12-12 11:21:39
问题 I have a div id="result" that I use to display results of users actions. I put there plain text and html too. After each user action this div is overwritten with new results . Now I want to display inside this div an instance of jsTree I have working jsTree that loads nicely on page load but it doesn't load after <div id="tree"></div> is inserted inside my result div. I tried two lines below but none worked. $("#tree").jstree("loaded"); $("#tree").jstree("refresh"); Any idea how to make the

jstree select_limit not working. I want to set selection limit to select only 3 nodes

耗尽温柔 提交于 2019-12-12 07:26:52
问题 My jstree function is here. I have set 'select_limit' : 3 , but is not working. when I run, I am able to select more than 3 nodes, but I need to select no more than 3 nodes. j1("#utree_activity").jstree({ "plugins": ["themes", "html_data", "ui", "crrm", "checkbox"], "html_data": { "ajax": { "url": urlGlobal + "jstrees/activitytree/", "asynchronous": "false", "data": function (n) { return { id: n.attr ? n.attr("id") : 0, default_activities: default_activities }; }, "success": function (gb) { }

jstree jquery how to iterate through all nodes

旧时模样 提交于 2019-12-12 07:24:59
问题 I'm trying to iterate through every node within a treeview in jstree. The treeview is 4 levels deep but I can't seem to get past the 1st level. The following is the jQuery used to iterate. $("#myTree").bind('ready.jstree', function (event, data) { $('#myTree li').each(function () { // Perform logic here } }); }); Here is a jsfiddle illustrating my point. Please help on how I can iterate through every node in jstree. 回答1: This gets all the children of your tree in a flat array for your .each

Webmethod is not fired by jsTree

…衆ロ難τιáo~ 提交于 2019-12-12 04:39:16
问题 I m trying to call web method from jsTree but unable to call it. can someone please help me out to get this resolved. my jsTree function is:- $('#tree').jstree({ "json_data": { "ajax": { "type": "POST", "dataType": "json", "async": true, "contentType": "application/json;", "opts": { "method": "POST", "url": "../../SurveyReport/Metrics.aspx/GetAllNodes11" }, "url": "../../SurveyReport/Metrics.aspx/GetAllNodes11", "data": function (node) { if (node == -1) { return '{ "operation" : "get_children

How do I split constructed jstree into 2 parts

末鹿安然 提交于 2019-12-12 04:18:55
问题 I am using jstree and jstree grid for contructing my tree structure. Can I split the constructed jstree into 2 parts? 回答1: You can split it with code as below. Check demo: Fiddle $("#tree1") .on("select_node.jstree", function(e, data) { // destroy second tree and remove DOM elements if ($("#tree2").find('ul').length > 0) { $("#tree2").jstree('destroy').empty(); } // get json format for branch to move selected node/branch from first tree var json = data.instance.get_json(data.node); // init

convert a nested set into data (json/html) for use in jstree

杀马特。学长 韩版系。学妹 提交于 2019-12-12 03:57:56
问题 I have a database with a table, in which data is stored as a nested set. The table looks like this: id lft rgt name depth 0 1 768 ROOT 0 550300 2 3 external 1 580943 4 5 teachers 1 510000 6 753 company BV 1 213000 7 14 Buying 2 913010 8 9 buying center 3 573100 10 11 buying generic 3 516300 12 13 buying service center 3 513900 15 48 finance 2 The data represents a company structure. I would like to display it with jstree I thought the best way to do that, was to first place it in a