简体   繁体   中英

ng-grid server side paging

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM