Skip to content

Conversation

@chiefy
Copy link

@chiefy chiefy commented Sep 3, 2013

When totalServerItems is updated, maxPages() wouldn't get evaluated until after the user changed the currentPage input, so maxPages() could be less than currentPage and Angular would change the currentPage to undefined (via it's max parser) which would result in badness.

…s for the min or max attributes in a number input. Also defaulting maxPages() to return 1 if maxRows is 0.
@tbertenshaw
Copy link

Hi @chiefy if i duplicate your changes in my ng-grid.js i get strange behaviour when clicking up and down a page. i have 55 items and its showing the first page of 5, if i click up to page2 the page increments but page2 doesnt load, if i thin click upto page3 it updates the pagenumber to 3 loads page2's data and changes the pagenumber to 2. if i examine the traffic using fiddler i can see it didnt call my webapi method in the first click but did in the second. This helpful?

@chiefy
Copy link
Author

chiefy commented Sep 3, 2013

@tbertenshaw Hmm, not sure. Since actually loading the data isn't really up to ng-grid, do you mind posting your code to a jsfiddle or something? I personally have a watch setup for $scope.pagingOptions.currentPage and when that changes, I fetch the appropriate data.

@tbertenshaw
Copy link

@c0bra
Copy link
Contributor

c0bra commented Sep 3, 2013

@tbertenshaw your getPagedDataAsync is operating within a setTimeout. Any time you're in an asynchronous callback you're breaking out of Angular's lifecycle, which means that promises won't get resolved properly. Your data is showing up on the second click because it initiates a new $digest cycle which resolves your queued $http calls.

If you inject $timeout and change setTimeout to $timeout it will work properly.

@tbertenshaw
Copy link

ok, cheers ill try this, incidentally my plnkr is a fork of of the serverside paging example on the main page http://angular-ui.github.io/ng-grid/

@tbertenshaw
Copy link

yeah that works now. Thanks @c0bra and @chiefy

roblarsen added a commit that referenced this pull request Sep 5, 2013
@roblarsen roblarsen merged commit 2e0fb05 into angular-ui:master Sep 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants