angular-ui/ui-grid

PaginationCurrentPage undefined

已关闭

#5,569 创建于 2016年7月20日

 (0 条评论) (0 个反应) (0 位负责人)JavaScript (2,496 个派生)batch import
good first issue

仓库指标

星标
 (5,395 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

http://plnkr.co/edit/pc6qKAud280qhgNEIE8G?p=preview

Modified the example from external pagination to show the error. Error occurs when changing items per page to 101. This is due to "options.paginationCurrentPage" on line 22256 being undefined when this watch get triggered due to some logic changing the currentPage number because that number wouldn't exist when increasing the items per page.

The other issue being on line 22262. The watch on this line doesn't get triggered because the oldValue (currentPage + items per page) is equal to 101 (100+1) , and the new value would also be 101 (undefined+101).

I originally thought about using $watchGroup on this instead, but because that was introduced in angular 1.3 or so, I decided against it, in order to support older versions.

I am not completely aware of where or why "options.paginationCurrentPage" gets set to undefined, so I ended up inserting a condition in the setShowing() on line 22256.

var setShowing = function () { if(!options.paginationCurrentPage) { options.paginationCurrentPage = 1; } $scope.showingLow = ((options.paginationCurrentPage - 1) * options.paginationPageSize) + 1; $scope.showingHigh = Math.min(options.paginationCurrentPage * options.paginationPageSize, options.totalItems); };

This would cause the math operations to not produce NaN, and also trigger the watch. While I am aware that this functionality is in alpha and this may not be the fix to the root of the issue, it is a workaround that I have started using in the meantime...

贡献者指南