3
votes

When I follow tutorial on pagination from angular-ui-grid site.

This code give me an error when page compile: gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { paginationOptions.pageNumber = newPage; paginationOptions.pageSize = pageSize; getPage(newPage -1, pageSize); });

"Error: gridApi.pagination.on is undefined

I'm using angularjs angular#1.3.11 and ui-grid 3.0.0-rc.16

2
I tried with version 3.0.0.-cr.18. Got same results. - Martin Paquin
I just tried with angular 1.2.28, got same results. - Martin Paquin
I was having all kinds of weird problems until I switched to using ui-grid-unstable.js as opposed to the RC files - mikerennick

2 Answers

14
votes

You may have not used pagination directive. In the module definition You should define pagination dependency:

   var app = angular.module('app', ['ui.grid', 'ui.grid.pagination']);

And in the HTML code You should use pagination directive :

   <div ui-grid="gridOptions" ui-grid-pagination class="grid"></div>

And there is another thing. Check your ui-grid code to existence of this line:ui-grid code

     paginationChanged: function (currentPage, pageSize) { }

If it does not exist, update your code to latest version of ui-grid

0
votes

Check if your app has 'ui.grid.pagination' module (top at file app.js).

Then make sure you had method onRegisterApi and get gridApi to your scope.

Next check if there is 'ui-grid-pagination directive' in your html.

Finally check if you didn't set 'enablePaginationControls' as false. It shoud be true (default settings).

It must work :)