0

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

    };

1 Answer 1

2

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);
            });
}
Sign up to request clarification or add additional context in comments.

2 Comments

value.userName means cel value in the grid?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.