ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 98 forks source link

Search plugin example #60

Closed EBS-EladRubin closed 8 years ago

EBS-EladRubin commented 8 years ago

Hi,

Thanks for this amazing Directive. Can we have a working example for search plugin?

Thanks!

ezraroi commented 8 years ago

Hi @EBS-EladRubin , I hope I will have some time this week or next week to try and write an example.

EBS-EladRubin commented 8 years ago

Hi thanks for the response, here is a working example: Under tree controller:

    //------------------------------------------------------------------------------------------------------------------//
    vm.applySearch = function (){
      var to = false;
      if(to) {
        clearTimeout(to);
      }
      to = setTimeout(function () {
        if(vm.treeInstance) {
          vm.treeInstance.jstree(true).search($scope.elementsTreeSearch);
        }
      }, 250);
    };
    //------------------------------------------------------------------------------------------------------------------//
ezraroi commented 8 years ago

Thanks!

morteza-gho commented 6 years ago

HTML

<input type="text" ng-model="search" ng-keyup="applySearch(search)" placeholder="search">
<div id="js-tree" js-tree="treeConfig" ng-model="tags" tree="treeInstance"></div>

JS

        $scope.applySearch = function (){
            var to = false;
            if(to) {
               clearTimeout(to);
            }
            to = setTimeout(function () {
               if($scope.treeInstance) {
                  $scope.treeInstance.jstree(true).search($scope.search);
               }
            }, 250);
         };