ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Pagination does not work

Open vuhailuyen1991 opened this issue 11 years ago • 39 comments

My app dependencies:

window.ethnicApp = angular.module 'ethnicApp', ['templates', 'ngRoute', 'ngResource', 'ui.router', 'angular-loading-bar',
                                                'angularFileUpload', 'ngAnimate', 'ui.grid', 'angular-underscore', 'ui.grid.pagination',
                                                'authModule', 'homeModule', 'itemsModule',
                                                'addItemModule', 'showItemModule']

My html

.grid ui-grid="itemsGridOptions" external-scopes='itemActionsManager' ui-grid-pagination=""

My Controller:

 $scope.itemsGridOptions = {
      paginationPageSizes: [10, 20, 30],
      paginationPageSize: 10,
      columnDefs: [
        { name: 'id' }
        { name: 'name' }
        { name: 'description' }
        { name: 'total_likes', displayName: '#Likes'}
        { name: 'seller.email' }
        { name: 'actions', displayName: 'Actions', cellTemplate: 'app/Items/Index/SubViews/ItemAction.html' }
      ]
    }

The page just show a table with 10 rows. No pagination sections at the bottom

vuhailuyen1991 avatar Jan 04 '15 08:01 vuhailuyen1991

Im in same situation. Very confused paging and pagination name. Something happened here?!, Merge pagination and paging features: https://github.com/angular-ui/ng-grid/commit/f8a68ccf7601a1a20f6b5234ad4fcaffa9f7a6fc It works for me with paging with v3.0.0-RC.18

$scope.gridOptions = { 
   enablePaging: true,
   pagingPageSizes: [10, 20, 30],
   pagingPageSize: 10,
angular.module('angularSonataAdmin', [ 'ui.grid.paging' ,'ngRoute', 'ui.grid', 'ui.grid.edit', 'ui.grid.resizeColumns', 'ui.grid.selection']
 div class="gridStyle" ui-grid="gridOptions" ui-grid-paging ui-grid-edit ui-grid-resize-columns ui-grid-selection

I hope I helped, but I do not know how to change the code later.

extdevelopment avatar Jan 04 '15 23:01 extdevelopment

Try ui-grid - v3.0.0-RC.18-f8a68cc - 2015-01-02 https://github.com/angular-ui/ng-grid/commit/f8a68ccf7601a1a20f6b5234ad4fcaffa9f7a6fc This version works with pagination

extdevelopment avatar Jan 05 '15 17:01 extdevelopment

Thanks @extdevelopment

vuhailuyen1991 avatar Jan 05 '15 17:01 vuhailuyen1991

So, just recently there were 2 modules - pagination and paging. Even back then ui.grid.paging wasn't always included into the JS file. 'Stable' RC-18 still has ui.grid.paging, while latest 'unstable' version (v3.0.0-RC.18-f8a68cc) doesn't have it anymore.

It seems that pagination took over from paging, but it works somewhat different. Plus, I'm getting all sorts of issues on IE9 with pagination now - displaying only few rows (out of 50 per many hundreds of pages), styling is all messed up. Not really sure as to why this switch was done.

alexandery avatar Jan 05 '15 18:01 alexandery

I'm also having an issue with external pagination. In onRegisterApi, I try to setup my paginationChanged event handler, but in gridApi.pagination.on.paginationChanged pagination is undefined. I do have useExternalPagination set to true.

futurechan avatar Jan 07 '15 19:01 futurechan

useExternalPagination: true, not use(r)ExternalPagination, but possible a typo in comment.

I use this code, and working properly.

    $scope.gridOptions.onRegisterApi = function(gridApi){
            gridApi.pagination.on.paginationChanged($scope, function (pageNumber, pageSize) {
                console.log('pager get data: pageNumber, pageSize', pageNumber, pageSize);
                getPager(pageNumber, pageSize); 
            });
    };

extdevelopment avatar Jan 07 '15 19:01 extdevelopment

@extdevelopment Yeah, it was just a typo. I'm using rc16. It looks like I need rc18. I ran bower install angular-ui-grid --save. Do I need to do something else?

futurechan avatar Jan 07 '15 21:01 futurechan

I think bower download only "main" release. You need it http://ui-grid.info/release/ui-grid-unstable.js v3.0.0-RC.18-d9b2314 - 2015-01-06 (this version currently available), because pagination refactored since RC.18

extdevelopment avatar Jan 07 '15 23:01 extdevelopment

the other component is also necessary, I forgot sry https://github.com/angular-ui/ng-grid#how-can-i-test-30

extdevelopment avatar Jan 07 '15 23:01 extdevelopment

Yeah, I'd build from master. The merge of paging and pagination has broken a few things. @brianchance may also have some thoughts.

PaulL1 avatar Jan 08 '15 22:01 PaulL1

I have been testing the paging and pagination with the latest unstable release, and it has been working fine. Just change the word paging to pagination everywhere.

When I first loaded the new .js file, I did have to clear my cache because I received the pagination not defined.

brianchance avatar Jan 08 '15 22:01 brianchance

@brianchance did you use bower to install the latest rc?

futurechan avatar Jan 12 '15 16:01 futurechan

I did not use bower, I grab them off the release site.

brianchance avatar Jan 12 '15 16:01 brianchance

Pagination styling is broken on IE9. Here are the screenshots from IE9 and FF of one of the tutorial pages:

IE9: pagination ie9

FF: pagination ff

alexandery avatar Jan 14 '15 21:01 alexandery

Thanks to the solution posted by @extdevelopment I was able to get pagination in 3.0 RC 18 (bower). Wish I started carousing the github issues a little sooner :)

ghost avatar Jan 19 '15 19:01 ghost

@kcaron-cst what was your bower install command? Last I tried, I got rc16.

futurechan avatar Jan 19 '15 21:01 futurechan

@futurechan this might be the reason: #2324

PaulL1 avatar Jan 19 '15 22:01 PaulL1

@futurechan I had to do a resolution in bower, but in my bower.json it looks like:

"angular-ui-grid": "3.0.0-RC.18"

ghost avatar Jan 19 '15 22:01 ghost

@kcaron-cst Did you make it work? I installed 3.0.0-RC.18. However, It doesn't work for me. :(

lvarayut avatar Feb 04 '15 09:02 lvarayut

@lvarayut (I am @kcaron-cst) This is on my todo list to figure out today. I have pagination controls, but requesting a new page just seems to clear the grid without redrawing the data. Are you not seeing the controls even? My relevant gridOptions are:

enablePaging  : true,
pagingPageSize: 100

& I am using gridApi.paging.on.pagingChanged as far as the API is concerned. I'm afraid I will be forced to switch versions to a nightly, which I've been avoiding it due to all the breaking changes, I'd rather deal with them all once RC19 is out.

kencaron avatar Feb 04 '15 13:02 kencaron