angularjs - Use filter input to search globally on server in angular ui-grid -


i using angular ui-grid display data.

i want use ui-grid's filter input used global search box. in, when type in filter input should make api call server.

i have similar on single column in grid. column has attribute "useexternalfiltering: true".

from columndefs

{ name: 'myfieldname', displayname: 'column name', useexternalfiltering: true, filter: { condition: uigridconstants.filter.contains }, }, 

then in controller have

$scope.gridoptions.onregisterapi = function (gridapi) {     $scope.gridapi = gridapi;      $scope.gridapi.core.on.filterchanged($scope, function () {         var grid = this.grid;         var columnindex = 1; // index of column want work         var termfrommycolumnofinterest = grid.columns[columnindex].filters[0].term;         $scope.loaddata(termfrommycolumnofinterest);         $scope.gridapi.core.notifydatachange(uigridconstants.datachange.all);     } }  $scope.loaddata = function (term) {     $q.all([         your_service_call(term).$promise     ])     .then(function (data) {         $scope.gridoptions.data = data[0];                     }, function () {         $scope.gridoptions.data = [];         // handle error     }); }; 

i hope helpful. simpler example, see http://ui-grid.info/docs/#/tutorial/308_external_filtering


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -