diff --git a/src/classes/footer.js b/src/classes/footer.js index f4eea99dc4..8d5c79990a 100644 --- a/src/classes/footer.js +++ b/src/classes/footer.js @@ -1,6 +1,6 @@ var ngFooter = function ($scope, grid) { $scope.maxRows = function () { - var ret = Math.max(grid.config.totalServerItems, grid.data.length); + var ret = Math.max($scope.totalServerItems, grid.data.length); return ret; }; @@ -12,7 +12,7 @@ $scope.pageForward = function() { var page = $scope.pagingOptions.currentPage; - if (grid.config.totalServerItems > 0) { + if ($scope.totalServerItems > 0) { $scope.pagingOptions.currentPage = Math.min(page + 1, $scope.maxPages()); } else { $scope.pagingOptions.currentPage++; @@ -36,7 +36,7 @@ $scope.cantPageForward = function() { var curPage = $scope.pagingOptions.currentPage; var maxPages = $scope.maxPages(); - if (grid.config.totalServerItems > 0) { + if ($scope.totalServerItems > 0) { return !(curPage < maxPages); } else { return grid.data.length < 1; @@ -44,7 +44,7 @@ }; $scope.cantPageToLast = function() { - if (grid.config.totalServerItems > 0) { + if ($scope.totalServerItems > 0) { return $scope.cantPageForward(); } else { return true; diff --git a/src/directives/ng-grid.js b/src/directives/ng-grid.js index 9d4ac365b5..910ed4d2f8 100644 --- a/src/directives/ng-grid.js +++ b/src/directives/ng-grid.js @@ -28,7 +28,16 @@ }, true); } else { grid.buildColumns(); - } + } + if (typeof options.totalServerItems == "string") { + $scope.$parent.$watch(options.totalServerItems, function (a) { + if (!a) { + $scope.totalServerItems = 1; + return; + } + $scope.totalServerItems = a; + }); + } // if it is a string we can watch for data changes. otherwise you won't be able to update the grid data if (typeof options.data == "string") {