forked from angular-ui/ui-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request angular-ui#1582 from PaulL1/external_filter_sort_f…
…alse Add useExternalFiltering option and event
- Loading branch information
Showing
6 changed files
with
294 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
[ | ||
{ | ||
"name": "Ethel Price", | ||
"gender": "female", | ||
"company": "Enersol" | ||
}, | ||
{ | ||
"name": "Claudine Neal", | ||
"gender": "female", | ||
"company": "Sealoud" | ||
}, | ||
{ | ||
"name": "Beryl Rice", | ||
"gender": "female", | ||
"company": "Velity" | ||
}, | ||
{ | ||
"name": "Georgina Schultz", | ||
"gender": "female", | ||
"company": "Suretech" | ||
}, | ||
{ | ||
"name": "Valarie Atkinson", | ||
"gender": "female", | ||
"company": "Hopeli" | ||
}, | ||
{ | ||
"name": "Lynda Mendoza", | ||
"gender": "female", | ||
"company": "Dogspa" | ||
}, | ||
{ | ||
"name": "Sarah Massey", | ||
"gender": "female", | ||
"company": "Bisba" | ||
}, | ||
{ | ||
"name": "Nellie Whitfield", | ||
"gender": "female", | ||
"company": "Exospace" | ||
}, | ||
{ | ||
"name": "Lelia Gates", | ||
"gender": "female", | ||
"company": "Proxsoft" | ||
}, | ||
{ | ||
"name": "Letitia Vasquez", | ||
"gender": "female", | ||
"company": "Slumberia" | ||
}, | ||
{ | ||
"name": "Blanche Conley", | ||
"gender": "female", | ||
"company": "Imkan" | ||
}, | ||
{ | ||
"name": "Kelli Leon", | ||
"gender": "female", | ||
"company": "Verbus" | ||
}, | ||
{ | ||
"name": "Freda Mason", | ||
"gender": "female", | ||
"company": "Accidency" | ||
}, | ||
{ | ||
"name": "Yvonne Parsons", | ||
"gender": "female", | ||
"company": "Zolar" | ||
}, | ||
{ | ||
"name": "Jocelyn Sawyer", | ||
"gender": "female", | ||
"company": "Fortean" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
[ | ||
{ | ||
"name": "Wilder Gonzales", | ||
"gender": "male", | ||
"company": "Geekko" | ||
}, | ||
{ | ||
"name": "Carroll Buchanan", | ||
"gender": "male", | ||
"company": "Ecosys" | ||
}, | ||
{ | ||
"name": "Schroeder Mathews", | ||
"gender": "male", | ||
"company": "Polarium" | ||
}, | ||
{ | ||
"name": "Robles Boyle", | ||
"gender": "male", | ||
"company": "Comtract" | ||
}, | ||
{ | ||
"name": "Evans Hickman", | ||
"gender": "male", | ||
"company": "Parleynet" | ||
}, | ||
{ | ||
"name": "Dawson Barber", | ||
"gender": "male", | ||
"company": "Dymi" | ||
}, | ||
{ | ||
"name": "Bruce Strong", | ||
"gender": "male", | ||
"company": "Xyqag" | ||
}, | ||
{ | ||
"name": "Jackson Macias", | ||
"gender": "male", | ||
"company": "Aquamate" | ||
}, | ||
{ | ||
"name": "Pena Pena", | ||
"gender": "male", | ||
"company": "Quarx" | ||
}, | ||
{ | ||
"name": "Trevino Moreno", | ||
"gender": "male", | ||
"company": "Conjurica" | ||
}, | ||
{ | ||
"name": "Barr Page", | ||
"gender": "male", | ||
"company": "Apex" | ||
}, | ||
{ | ||
"name": "Kirkland Merrill", | ||
"gender": "male", | ||
"company": "Utara" | ||
}, | ||
{ | ||
"name": "Atkins Dunlap", | ||
"gender": "male", | ||
"company": "Comveyor" | ||
}, | ||
{ | ||
"name": "Everett Foreman", | ||
"gender": "male", | ||
"company": "Maineland" | ||
}, | ||
{ | ||
"name": "Gould Randolph", | ||
"gender": "male", | ||
"company": "Intergeek" | ||
}, | ||
{ | ||
"name": "Tucker Maxwell", | ||
"gender": "male", | ||
"company": "Lumbrex" | ||
}, | ||
{ | ||
"name": "Woods Key", | ||
"gender": "male", | ||
"company": "Bedder" | ||
}, | ||
{ | ||
"name": "Stephens Reilly", | ||
"gender": "male", | ||
"company": "Acusage" | ||
}, | ||
{ | ||
"name": "Mcfarland Sparks", | ||
"gender": "male", | ||
"company": "Comvey" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@ngdoc overview | ||
@name Tutorial: 308 External Filtering | ||
@description | ||
|
||
Sometimes you want to filter data externally, either on the client using custom filter routines, or on | ||
the server as part of your data retrieve. | ||
|
||
UI-Grid provides two functions that support this, firstly a filterChanged event that tells you when a user has | ||
changed their requested filter using the grid ui, and secondly a useExternalFiltering property to turn off | ||
the grid native filtering. | ||
|
||
@example | ||
In this example we suppress the internal filtering, and emulate an external filter by picking one of three | ||
json files to show - one filtered by gender 'male', one filtered by gender 'female', and one not sorted. | ||
|
||
To further illustrate that this is using external sorting, the external filter routine (consisting of me manually | ||
editing json files) got bored of filtering after the first 10 or so rows, and deleted all other rows in the file. | ||
|
||
<example module="app"> | ||
<file name="app.js"> | ||
var app = angular.module('app', ['ui.grid']); | ||
|
||
app.controller('MainCtrl', ['$scope', '$http', '$interval', 'uiGridConstants', function ($scope, $http, $interval, uiGridConstants) { | ||
|
||
$scope.gridOptions = { | ||
enableFiltering: true, | ||
useExternalFiltering: true, | ||
columnDefs: [ | ||
{ name: 'name', enableFiltering: false }, | ||
{ name: 'gender' }, | ||
{ name: 'company', enableFiltering: false} | ||
], | ||
onRegisterApi: function( gridApi ) { | ||
$scope.gridApi = gridApi; | ||
$interval(function() { | ||
$scope.gridApi.core.on.filterChanged( $scope, function() { | ||
var grid = this.grid; | ||
if( grid.columns[1].filters[0].term === 'male' ) { | ||
$http.get('/data/100_male.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
} else if ( grid.columns[1].filters[0].term === 'female' ) { | ||
$http.get('/data/100_female.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
} else { | ||
$http.get('/data/100.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
} | ||
}); | ||
}, 200, 1); | ||
} | ||
}; | ||
|
||
$http.get('/data/100.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
|
||
}]); | ||
</file> | ||
<file name="index.html"> | ||
<div ng-controller="MainCtrl"> | ||
<div ui-grid="gridOptions" class="grid"></div> | ||
</div> | ||
</file> | ||
<file name="main.css"> | ||
.grid { | ||
width: 500px; | ||
height: 250px; | ||
} | ||
</file> | ||
</example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters