How to Implement Excel Like Filter in angularjs?

后端 未结 2 1346
情深已故
情深已故 2021-02-08 02:48

I Need to Implement simple Excel Like Filer for table using angulajs(v.1) I\'m getting stuck please help me, I have added my code snippet below. I want to show filtered Data in

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 03:20

    Change ng-model to have one dummy variable lets say emp.status whose value will be either true or false based on clicking checkbox.

    HTML country dropdown

  •  
  • Controller :

      var countrySet = [];
      $scope.employees=employees;
      $scope.showResults=employees;
      function  _setFilterData(){
          var emplList = angular.copy(employees);
    
          $scope.showResults = emplList.filter(function(v, idx){
              return countrySet.includes(v.Country)
          });  
      }
      $scope.yourFunction = function(checkBoxStatus, country){
          var index = countrySet.indexOf( country ); 
    
            if(checkBoxStatus && index === -1 ) {
                countrySet.push( country); 
    
            }else{
              countrySet.splice( index, 1 );
            }
            _setFilterData();
            console.error(checkBoxStatus, country, countrySet);
        }
    

    Please check plunker for functionality : https://plnkr.co/edit/aXhvM0?p=preview

    NOTE: Never mind CSS on plunker

提交回复
热议问题