ng-grid server side paging

瘦欲@ 提交于 2019-12-11 20:13:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!