jstree

How to update jstree node values without reload

末鹿安然 提交于 2019-12-20 18:30:33
问题 I have a jstree that I created with the following code: $('#mytree').jstree({"core": { "data" : value , "themes" : { "dots": false , "icons": false } } } ); I can rebuild it with new data by this code: $('#mytree').jstree(true).settings.core.data = new_data; $('#mytree').jstree(true).refresh(); but it can be expensive when you have a lot of nodes. What I would like to achieve is that I would like update the value of the elements (i.e. the node.text part) without rebuilding the whole tree. I

How to redraw jstree tree with new data?

天大地大妈咪最大 提交于 2019-12-20 11:22:08
问题 So, my question. I initialized my tree with some data: $('#tree').jstree({ 'core' : { 'data' : [ 'Simple root node', { 'id' : 'node_2', 'text' : 'Root node with options', 'state' : { 'opened' : true, 'selected' : true }, 'children' : [ { 'text' : 'Child 1' }, 'Child 2'] } ] }); But after some actions, I want to redraw tree with new data. I try to use refresh and redraw methods from API, but it unsuccessfully. Can you give me advice, how to refresh tree (without destroy -> create new instance

Meteor `Deps.autorun` vs `Collection.observe`

一曲冷凌霜 提交于 2019-12-20 10:06:06
问题 What are the pros/cons between using Deps.autorun or Collection.observe to keep a third-party widget in sync with a reactive Meteor.Collection . For example, I am using jsTree to visually show a directory tree that I have stored in my MongoDB. I'm using this code to make it reactive: // automatically reload the fileTree if the data changes FileTree.find().observeChanges({ added: function() { $.jstree.reference('#fileTree').refresh(); }, changed: function() { $.jstree.reference('#fileTree')

How to select a specific node programmatically?

烂漫一生 提交于 2019-12-20 09:47:58
问题 I have a jstree. I want to select the node which is bound to the object which has a location with id of 158. This works but seems stupid. What's the more idiomatic way of doing this? var $tree = $('.jstree', myContext), node = $tree.find('li').filter(function() { return ( $(this).data().location || {}).id === 158; }); $tree.jstree('select_node', n) 回答1: Just wanted to chime in here as none of the answers worked for me. What finally DID work was very simple: $('#someTree').jstree('select_node'

JSTree adding nodes to child nodes

无人久伴 提交于 2019-12-20 04:59:10
问题 I am using JSTree with a MVC project and I am trying to add child nodes to the tree, however I am getting a null refference error Object reference not set to an instance of an object on the line subGroupNode.children.Add(itemNode); I guess this is because the subGroupNode.Children is empty. how can it be when the child is created in the previous foreach loop. public JsonResult GetJsTree3Data() { var marketGroups = new List<JsTree3Node>(); // Create our root node and ensure it is opened var

Get checked nodes in a jsTree

半世苍凉 提交于 2019-12-20 02:27:56
问题 I have a working JSTree based on JSON data, and the checkbox plugin displays boxes next to each item -- so far so good. Now I want to get which nodes the user has checked, so I can do something with the data. Unfortunately I haven't found a way to do it through the documentation or web searches. A few answers on SO say to use a get_checked method, but either I'm really missing something or my version of JSTree doesn't have that (i.e. that string doesn't appear anywhere in the project files).

jsTree search with Ajax/JSON not calling URL

删除回忆录丶 提交于 2019-12-19 19:47:13
问题 I would really appreciate some help with the following: I have a jsTree loaded with JSON data via a URL. All the data is preloaded. What I need to do is change the search functionality to reload the entire tree with new JSON data via AJAX based on the user input (because I need to do more complex node searching in the backend). As a start all I am trying to do is to get the jsTree code to call my URL. I started with the same URL as I use to originally load the tree. However - and this is the

JsTree v3.0 drag and drop plugin. Reference target node upon dropping

佐手、 提交于 2019-12-19 17:38:14
问题 I use drag and drop plugin of jsTree library (ver. 3.0) With the following code I can bind to the end of drag'n'drop action, but I can not see a way to get the reference to the target node (the node I'm dropping on). $(document).on('dnd_stop.vakata', function(e, data) { // how to get target_node here? }); 回答1: Another solution is to use the get_node() function on the jstree object. $(document).on('dnd_stop.vakata', function (e, data) { ref = $('#jstree').jstree(true); parents = ref.get_node

Populating jstree from xml string

跟風遠走 提交于 2019-12-19 10:17:43
问题 I am trying to populate a jstree container with data from a string describing an xml document. Here's my code, with a simplified xml document: var xmlText = "<root>A<node>B</node></root>"; var xml = (new DOMParser()).parseFromString(xmlText,'text/xml'); $('#jstree').jstree({"core": {data: xml.documentElement}}); (also on codepen: http://codepen.io/szymtor/pen/XKqApq/). The result is a well-structured tree, but without node labels (see image below). How should I provide the node labels? Or am

Get the immediate parent of child node in jstree

匆匆过客 提交于 2019-12-19 10:13:30
问题 I want to retrieve the parent of the child node without clicking on the tree .. data.inst._get_parent(data.rslt.obj).attr("id"); Above command give me the immediate parent when we click on the child nodes . Is there a way to get the parent node without clicking on the child node . Regards, Praque M 回答1: It seems the "data.inst" was renamed in newer versions to "data.instance". This made tracking down the solution difficult data.instance.get_parent(data.node) returns the string ID of the