angular-bootstrap-nav-tree icon indicating copy to clipboard operation
angular-bootstrap-nav-tree copied to clipboard

Search filter for the angular-bootstrap-nav-tree

Open natiyer opened this issue 10 years ago • 4 comments

Hi Nick,

Do you know if there is an implementation of a search filter that will work with the angular-bootstrap-nav-tree?

Thanks,

natiyer avatar Aug 05 '14 16:08 natiyer

I would also like to filter elements from the nav-tree using a search input, any idea?

benoror avatar Feb 11 '15 16:02 benoror

I would like too use a search filter on abntree. Any idea ?

christophechevalier avatar Jun 10 '15 13:06 christophechevalier

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

shazadmaved avatar Sep 09 '15 17:09 shazadmaved

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;


     }

}

shazadmaved avatar Sep 09 '15 18:09 shazadmaved