Angularjs ui-grid Filter from text input field Angularjs ui-grid Filter from text input field angularjs angularjs

Angularjs ui-grid Filter from text input field


The answer to your first question, they have not really made a global search option for the UI-Grid yet, so you have to do a bit of a work around. The current way that the column filters work is angular watches the column filter input field for a change, and when you type in the box, it refreshes its filter. So your filter will not apply unless you force this input box to fire the change event. The workaround is to simply filter the data and reload. For example:

In your HTML input search box, add a refresh

<input ng-model="searchText" ng-change="refreshData()" placeholder="Search...">

then in your app.js

$scope.refreshData = function() {  $scope.myGrid.data = $filter('filter')($scope.data, $scope.searchText);};

oh, and don't forget to include $filter in your controller

app.controller('myController', function($scope, $filter) {}

I forked your example and modified it with this workaround. Check it out here:http://plnkr.co/edit/Tr9cNm0lDy62dmF7LNlr?p=preview


try this:

$scope.gridOpts = {    data: myDummyData,    enableFiltering: true,    columnDefs: [                {name: 'Name', field: 'name', enableFiltering: true                    , filter: {                        noTerm: true,                        condition: function(searchTerm, cellValue) {                            return (cellValue+"" === $scope.filterOptions.filterText+"");                        }                    }                },                {name: 'Price', field: 'age'}            ]};

for input box: <input ng-model="searchText" ng-change="refresh()" placeholder="Search...">

$scope.refresh = function(){    $scope.gridApi.core.refresh();}

I hope it works...