Comments (13)
jqTree has no function for that.
You could do something like this:
var $tree = $('#tree1');
$('#collapse').click(function() {
var tree = $tree.tree('getTree');
tree.iterate(function(node) {
if (node.hasChildren()) {
$tree.tree('closeNode', node, true);
}
return true;
});
});
$('#expand').click(function() {
var tree = $tree.tree('getTree');
tree.iterate(function(node) {
if (node.hasChildren()) {
$tree.tree('openNode', node, true);
}
return true;
});
});
from jqtree.
You can use the autoOpen option to open nodes when the tree is loaded. See http://mbraak.github.com/jqTree/#tree-options-autoopen
You can also use the openNode function to open a node programmatically. This function is not documented yet.
For example in demo.html:
var node = $('#tree1').tree('getNodeById', 23);
$('#tree1').tree('openNode', node);
from jqtree.
But that will expand the tree, I want to do the opposite, so collapsing (closing) the tree
from jqtree.
Oops. There is no function for that yet. Would be a nice feature for the next release.
from jqtree.
The dev branch now contains the function closeNode.
var node = $('#tree1').tree('getNodeBydId', 23);
$('#tree1').tree('closeNode', node);
To close a node without animation:
$('#tree1').tree('closeNode', node, true);
from jqtree.
Hello,
Is there a way to do an expand all/collapse all?
Thanks,
~/Jota
from jqtree.
Hello
I need to append my child node below their parent node dynamically from db through ajax call. I tried with openNode, addNodeAfter its not viewing. But i tried with append node its showing the child node last of all the parent node.
from jqtree.
Let me see if I understand you correctly. You want to add a child node to a parent node; the new node must be the first child.
Is that correct?
from jqtree.
yes
from jqtree.
There is no 'add-first-child' function. But you can use the addNodeBefore function.
Here is an example:
// appendNodeFirst: add 'new_node' as first child to 'parent_node'
function appendNodeFirst($tree, new_node, parent_node) {
if (parent_node.children && parent_node.children.length != 0) {
// Parent has children; add before first child
var first_child = parent_node.children[0];
$tree.tree('addNodeBefore', new_node, first_child);
}
else {
// Parent has no children; append node
$tree.tree('appendNode', new_node, parent_node);
}
}
var parent_node = $tree.tree('getNodeById', 1);
var new_node = {
label: 'new child',
id: 6
};
from jqtree.
how to merge the nodes
from jqtree.
how to replace rootnode child nodes
from jqtree.
@urprasu
Can you give give an example of how you want to merge nodes?
from jqtree.
Related Issues (20)
- Issue while trying to load a little bit large amount of nodes HOT 1
- Disable opening folders during drag & drop HOT 5
- Selected Node Problem HOT 2
- Possible to open a particular node at jqTree creation time? HOT 1
- Cannot find node with getNodeById HOT 12
- Functions getNextNode() and getPreviousNode() operate differently based on whether node is open or closed HOT 4
- Question: Is is possible to find a node using its path? HOT 1
- What can I do if I choose only child multiple times HOT 6
- How to export and import jqTree data? HOT 9
- Rename selected node HOT 3
- Autoscroll - top level dragged item no scroll over the items under it. HOT 20
- Feature: ES6 support HOT 9
- Behavior changed with 1.7.0 HOT 3
- Set jQuery as a peer dependency
- Fix eslint import error
- Is documentation page dead? HOT 4
- Inconsistent/incorrect drag & drop node highlighting HOT 9
- New root node missing icon HOT 3
- AddToSelection doesn't seem to use "mustSetFocus" HOT 4
- How to use jqTree with jQuery latest version 3.7.1 in ASP.NET HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jqtree.