Skip to content

Commit

Permalink
Merge pull request #57 from marmelab/fix_pagination_count
Browse files Browse the repository at this point in the history
[RFR] Fix datagrid pagination count
  • Loading branch information
manuquentin committed Sep 28, 2014
2 parents ed93685 + 313bcec commit 4d6c15a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ define(function() {
this.$anchorScroll = $anchorScroll;
this.CrudManager = CrudManager;
this.infinitePagination = this.$scope.hasPagination && this.$scope.entityConfig.infinitePagination();

if (this.$scope.hasPagination) {
this.computePagination();
}
}

DatagridPaginationController.prototype.computePagination = function () {
Expand All @@ -22,7 +18,7 @@ define(function() {
totalItems = this.$scope.totalItems;

this.currentPage = currentPage;
this.offsetBegin = (currentPage - 1) * perPage;
this.offsetBegin = (currentPage - 1) * perPage + 1;
this.offsetEnd = Math.min(currentPage * perPage, totalItems);
this.totalItems = totalItems;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ define(function(require) {
restrict: 'E',
template: datagridView,
controllerAs: 'datagrid',
controller: DatagridController,
link: function(scope, element, attrs) {
scope.hasPagination = typeof(attrs.withPagination) === 'undefined' ? true : scope.$eval(attrs.pagination);
}
controller: DatagridController
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ define(function(require) {
var offset = attrs.offset || 100,
body = $document[0].body;

scope.hasPagination = !element.parent()[0].hasAttribute('with-pagination') ? true : scope.$eval(element.parent()[0].getAttribute('with-pagination'));
if (scope.hasPagination) {
controller.computePagination();
}

angular.element($window).bind('scroll', function () {
if (body.offsetHeight - $window.innerHeight - $window.scrollY < offset) {
scope.$apply(controller.nextPage.bind(controller));
Expand Down

0 comments on commit 4d6c15a

Please sign in to comment.