jstree

how to get the metadata of jsTree.

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 03:56:53
This is my code: $("#demo1").jstree({ "themes": { "theme": "default", "dots": true, "icons": true, "url": "static/themes/default/style.css" }, "ui" : { // this makes the node with ID node_4 selected onload "initially_select" : [ location.hash.slice(1).split('@')[1]] }, "json_data" : { "data" : [ { "data" : "A node", "attr" : { "id" : "1" ,time:1321}, "callback":function(){alert('sss')}, "children" : [ { "data" : "ttt node", "children" : [ "Child 1", "Child 2" ] } ] }, { "attr" : { "id" : "2" }, "data" : { "title" : "Long format demo", "attr" : { "href" : "#" } } }, { "data" : "sss node", "attr

jsTree : How to get all nodes from jstree?

梦想的初衷 提交于 2019-11-29 03:54:35
How to get all nodes present in jsTree? I am building jsTree with xml Root -----A -----A1 -----A1.1 -----A1.2 -----A2 -----`A2.1` -----A2.2 -----B -----B1 -----B2 -----C -----C1 -----C1.1 -----C2.2 I want array of all nodes(ID) present in jsTree is as follows Expected output: [Root, A, A1, A1.1, A1.2, A2, A2.1, A2.2, B, B1, B2, C, C1, C1.1, C2.2] montrealist From documentation : .get_json ( node , li_attr , a_attr ) This function returns an array of tree nodes converted back to JSON. More info about same function from this doc : This function traverses the whole tree and exports it as JSON.

How to associate a data to a node in jstree?

那年仲夏 提交于 2019-11-29 02:56:17
问题 $("#ifTree").jstree({ "plugins" : ["themes","html_data","ui","crrm"], "themes" : { "theme" : "apple", "dots" : true, "icons" : false } }); $("#createIf_c").click(function () { $("#ifTree").jstree("create",null,"inside", { "data" :{ title:"if",value:"expression"} }, function() {}, true); }); $("#display").click(function(){ var a = $.jstree._focused().get_selected(); alert(a.attr("value")); }); In this above code I have created a jstree and upon click of a button with id #createIf_c I am adding

Recreate entire jstree instance with new json data

心不动则不痛 提交于 2019-11-29 02:18:33
问题 I wish to replace the entire contents of a jstree tree with new json data. I'm using jsTree 1.0 downloaded July 25, 2011 from github Say I have this function... function init_my_tree(my_json_data) { $("#demo1").jstree({ themes: { "theme": "classic", "dots": false, "icons": true, "url": "//js.myliburl.com/jstree/themes/classic/style.css" }, json : { data : my_json_data }, plugins : [ "core","ui","themes", "json" ] }); } where demo1 refers to a <div id="demo1"></div> What I'm trying to do is to

jsTree : How to get IDs of selected nodes to root node in jsTree?

隐身守侯 提交于 2019-11-28 23:33:19
How to get IDs of selected nodes to root node in jsTree? Assume C is selected node then How can I get All parent IDs of C. A B C +C1 +c2 Following code will return only immediate parent ID: If I selected C then I get only B .bind("select_node.jstree", function (event, data) { //`data.rslt.obj` is the jquery extended node that was clicked alert("Selected node = "+ data.rslt.obj.attr("id")); alert("Parent of Selected node = "+ data.inst._get_parent(data.rslt.obj).attr("id")) }); Output: Selected node = C Parent of Selected node = B Is there any way to get all parent nodes ID i.e. Selected node

dnd, how to restrict dropping to certain node types?

ⅰ亾dé卋堺 提交于 2019-11-28 20:24:21
I have 37 different node types. I am trying to implement drag and drop. This works but I need to restrict exactly which types can be dragged and where they can be dropped. I can't find any useful information in the docs unfortunately (http://www.jstree.com/documentation). So far I have tried three methods: first: defining return values of true or false in the drag_check callback depending on the node type: $("#demo1").jstree({ "dnd" : { "drag_check" : function () { second: binding to the prepare_move.jstree event and returning true or false values depending on the node type: .bind("prepare

How to get all checked nodes in jstree?

喜欢而已 提交于 2019-11-28 13:11:13
I need to export my nodes like this: function recursive_simplify(node){ if(node.children){ for(var i =0;i<node.children.length;i++){ node.children[i] = recursive_simplify(node.children[i]) } } delete node['metadata']; return node } $('body').on('click','.data-export', function () { var tree=$.jstree._reference('#reference-data-exchange'); var checked = tree.get_checked(); var result = []; for(var i=0, checkedLength = checked.length; i<checkedLength;i++) { var checkedJson = tree.get_json(checked[i],['id','rel','data-bin','data-pos'])[0]; checkedJson = recursive_simplify(checkedJson); result

creating dynamic jstree using alternative JSON format stored in array

徘徊边缘 提交于 2019-11-28 11:47:44
I am able to create jstree using alternative JSON format as below: $('#using_json_2').jstree({ 'core' : { 'data' : [ { "id" : "ajson1", "parent" : "#", "text" : "Simple root node" }, { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" }, { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" }, { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" }, ] } }); But it is quite static. I want it to be dynamic; in the sense that, number of rows could be variable and row properties to be read from an array. I don't want to use ajax as data is already available in array. If you want

Setting line-height on a jsTree?

回眸只為那壹抹淺笑 提交于 2019-11-28 09:38:15
问题 I'm using jstree to create a multi-level tree, and I want to be able to set a larger line-height than you usually see, so that I can have some large headings. (If I set the font larger, the lines simply overlap.) I've tried setting the line-height CSS property on the li and a elements, but neither have an effect; jstree seems to be programmatically overriding those values. (I even tried using jQuery to re-set those values after the tree is created, but that didn't help.) To make things more

jsTree Context Menu selected item?

假装没事ソ 提交于 2019-11-28 09:18:04
问题 We're working with jsTree (revision 236 from 09/02/2011). Does anyone know if there is any way to access the menu item name selected in the function associated with the "action"? I want to automate the definition of menu items, so that the functionality of the "action" for each are set based on the identifier of the item in the contextual menu. For example, for a context menu with three actions ("A", "B" or "C") ... var items = {}; for(var i=0; i < preconfiguredItemsData.length; i++) { var