问题
I'm a little confused on how to use the sever side paging for ng-grid. (http://angular-ui.github.io/ng-grid/)
Can someone point me in the right direction on how to achieve this on the server side? The example shows a static json file. How and where are the parameteres set for limit and offset so I can adjust my sql query and output. It seems on the surface it is all loaded at once.
Thanks. I know this may get down votes but had to take the chance.
回答1:
Not sure if this helps you because I use the SLIM Framework for routing and MEEKRO as mysql famework on my serverside. But it comes down to this:
This is what my getPagedDataAsync
function looks like
$scope.getPagedDataAsync = function (pageSize, page, sorting,searching) {
$http.get('db_api.php/'+pageSize+'/'+page+'/'+sorting.sortfield+'/'+sorting.sortdir+'/'+searching).success(function (data) {
$scope.profiles = data.result;
$scope.totalServerItems = data.all;
$scope.filtered = data.filtered;
if (!$scope.$$phase) {
$scope.$apply();
}
});
};
It sends a GET request to my php script with the parameters that are gathered by the watchers. Unlike the example this takes also the sortOptions
into account. If you don't want to use a routing framework on the server side you should replace the slashes with the usual questionmark ampersand notation.
By looking at your rep I think this should already give you a clue. Come back if you need further help on the sql query.
来源:https://stackoverflow.com/questions/24516502/ng-grid-server-side-paging