angular-bootstrap-nav-tree
angular-bootstrap-nav-tree copied to clipboard
Search filter for the angular-bootstrap-nav-tree
Hi Nick,
Do you know if there is an implementation of a search filter that will work with the angular-bootstrap-nav-tree?
Thanks,
I would also like to filter elements from the nav-tree using a search input, any idea?
I would like too use a search filter on abntree. Any idea ?
me too.... done a recursive function half way.. n thought to search if i can find something online....... I think i need to complete it
HTML: Input search :
ABN Tree: <abn-tree tree-data="state_variables.final_tree" icon-leaf = "fa fa-folder-open" icon-expand = "fa fa-folder" icon-collapse = "fa fa-folder-open" on-select = "my_tree_handler(branch)" tree-control = "document_tree"
ANGULARJS: //on search change $scope.filterTree = function(){ $scope.searched_array = []; $scope.document_tree.expand_all();
if($scope.searchFolder==''){
/* if empty then create the tree json using my custom function to reinitialize */ $scope.state_variables.final_tree = $scope.convertToHierarchy( $scope.hierarchy ); }else{ $scope.returnsearch($scope.state_variables.final_tree[0] , $scope.searchFolder);
}
}
/recursive function to search the tree nested json from top to bottom/ $scope.returnsearch = function( tree,s){
if( tree.folder_name.indexOf(s) != -1 ){
$scope.searched_array.push(tree);
}
if(tree.children.length != 0){
$.each(tree.children , function(index , node){
$scope.returnsearch(node , s);
});
}else{
$scope.state_variables.final_tree = $scope.searched_array;
}
}