Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have created a custom filter in AngularJs UI-grid.The filter is working fine with a single argument but when it comes to multiple values filter didn't work well.Please if any one knows how to pass multiple parameters into UI grid filter let me know.

AngularJs Filter Method

Filter will execute when button on click and redraw the grid according to user name.

    $scope.filterData = function(userName) {
           $scope.searchText = userName;
           $scope.tableData.data = $filter('filter')
            ($scope.TestData,
            $scope.searchText, undefined);
//how can i pass multiple param into filter like filtering based on user name and age

    };
share|improve this question
up vote 1 down vote accepted

Pass any number of parameters. But while using filter tag, use function instead of a single parameter.

See the code below for reference.

$scope.filterData = function(userName, secndParm, thirdParm,...) {          
           $scope.tableData.data = $filter('filter')
            ($scope.TestData, function (value, key) {
               return  (value.userName == userName || value.someText == secndParm || value.someAntherText == thirdParm);
            });
}
share|improve this answer
    
value.userName means cel value in the grid? – gihan 21 hours ago
    
values are individual objects of the Array you are going to search the results for. So with this approach u can compare with each attribute(of each object) u wanna do. – vamshi krishna 21 hours ago
    
thanks it works fine. – gihan 3 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.