Filter with children included
I am trying to create a filter that will not only show the parent nodes but also show all child nodes of the filtered node.
here is a similar issue: https://github.com/mbraak/jqTree/issues/230
All i'm asking for is to display everything below the filtered node along with the parent node
Ex: in the below image, if i search "Root" it will show all the tree because all nodes fall under the "Root Node" node.

Or if i searched "Child Node 3" the "Root Node" node will show because it is the parent but also "Child child 1" & "Child child 2" nodes will show because they are under the searched "Child Node 3":

Here is a Fiddle of my example(fyi: code borrowed): http://jsfiddle.net/uidezigns/xfkjQ/
Go throw following link for filter on JQTree
http://jsfiddle.net/chetanchaudhari03/hzvQ6/9/
@ChetanChaudhari03, thanks for your input, but please re-read my post, this fiddle(http://jsfiddle.net/chetanchaudhari03/hzvQ6/9/) doesn't solve my issue, I'm not looking for a generic Filter that only shows what is in the filter input. I am looking for the tree to also show the children of the keyword input into the filter, more specifically, all the sub-tree items of the filtered keyword. Does this make sense?
@mbraak, adding you so you can review the issue.
Any help is greatly appreciated!!
@mbraak, @parktheredcar, @dmalatesta, @rosenfeld, @dot, @lukeb,
Please take a look into my issue.
Fixed it my self. Take a look if you have this issue... http://jsfiddle.net/uidezigns/xfkjQ/
tree.tree({
data: data,
//dragAndDrop: true,
autoOpen: true,
useContextMenu: false,
onCreateLi: function (node, $li) {
var title = $li.find('.jqtree-title');
var search = filter.val().toLowerCase();
var value = title.text().toLowerCase();
if (search !== '') {
var _parent = node.parent;
var _parentValue = (typeof _parent.name === 'string')? _parent.name.toLowerCase() : "";
$li.hide();
while (typeof (_parent.element) !== 'undefined') {
if (value.indexOf(search) > -1 || _parentValue.indexOf(search) > -1) {
$li.show();
$(_parent.element).show().addClass('jqtree-filtered');
}
_parent = _parent.parent;
_parentValue = (typeof _parent.name === 'string')? _parent.name.toLowerCase() : "";
}
if (!_filtering) {
_filtering = true;
};
if (!tree.hasClass('jqtree-filtering')) {
tree.addClass('jqtree-filtering');
};
} else {
if (_filtering) {
_filtering = false;
};
if (tree.hasClass('jqtree-filtering')) {
tree.removeClass('jqtree-filtering');
};
};
},
onCanSelectNode: function (node) {
if (node.children.length == 0) {
// Nodes without children can be selected
return true;
}
else {
// Nodes with children cannot be selected
return false;
}
}
});