Hiding nodes

2,193 views
Skip to first unread message

andrewjg

unread,
Sep 6, 2011, 9:54:22 PM9/6/11
to Discuss jquery.dynatree.js
Hi there,

Dynatree is working really well for me so far, but is there a
relatively easy way to hide nodes? I want to implement a filtering
system where only nodes with titles that match a specified search
string are visible. Do I need to rebuild the tree or can I just toggle
the visibility of a node? Thanks.

Cheers, Andrew.

mar10

unread,
Sep 7, 2011, 1:48:23 AM9/7/11
to dyna...@googlegroups.com
I would try to use visit() to traverse the tree and set a special class name for hidden nodes. Then add ths clss to the css.
Note that you must not hide parents of visible nodes, of course...

andrewjg

unread,
Sep 7, 2011, 6:13:45 PM9/7/11
to Discuss jquery.dynatree.js
Thanks for that - it's what I ended up doing:

RCS.StationPicker.prototype.filterNodes = function(searchTerm,
targetNode)
{
// Only show nodes matching the specified search term
var startNode = targetNode ||
this.availableStationsTree.dynatree("getRoot");
startNode.visit(function(node)
{
if (node.isVisible() && node.data.title)
{
// Filter currently visible non-root nodes.
if (node.data.title.indexOf(searchTerm) >= 0)
{
// Make sure we and all our parents are visible
node.visitParents(function(node)
{
$(node.li).show();
return (node.parent != null);
}, true);

// Terminate the traversal of this branch since the
node matches
return 'skip';
}
else
{
// Hide the node.
$(node.li).hide();
}
}
});
}

ali.abbas

unread,
Sep 10, 2012, 6:24:25 AM9/10/12
to dyna...@googlegroups.com, andrew...@gmail.com
Hi
can you please guide me that how you fix this problem to hide the and show the nodes of dynatree.
your urgent reply will be highly appreciated

thanks

mohit...@gmail.com

unread,
May 22, 2014, 7:29:30 AM5/22/14
to dyna...@googlegroups.com, andrew...@gmail.com
Hi actually i have implemneted the dynatree , now i want filter capability like , User input caures in text and on kerpress event it shoud show the filtered node and child node.
any help apriciated.

mar10

unread,
May 22, 2014, 3:23:27 PM5/22/14
to dyna...@googlegroups.com, andrew...@gmail.com, mohit...@gmail.com
I would suggest to look at Fancytree and the ext-filter extension: http://wwwendt.de/tech/fancytree/demo/sample-ext-filter.html
Reply all
Reply to author
Forward
0 new messages