4

Examples and links from How to do paging in AngularJS? all show pagination system where the filtering/ordering only apply to current page.

For instance, sorting by id on the 1st page of this fiddle will switch :

  • between: 1, 10, 11, 12, 13 ;
  • and this : 13, 12, 11, 10, 1.

While someone might expects to get :

  • 1, 2, 3, 4, 5 (as those values are present in following pages).

Question

How would someone filter/order then paginate instead of paginate then filter a list ?

1
  • are you concerned about the sorting algorithm as well, or just sorting on the entire set? If we apply the same sorting algorithm to the entire set, the values one should expect are 1, 10, 11, 12, 13 Commented Mar 9, 2014 at 6:54

1 Answer 1

2

1) Stop sorting on paged results

Before:

<tr ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse">

After:

<tr ng-repeat="item in pagedItems[currentPage]">

2) Inject $filter and sort on the entire set

$filter('orderBy')($scope.items, $scope.sortingOrder, $scope.reverse);

... Here is a modified fork of your fiddle

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, that's what I finally did. however the sorting is kind of slow, I will need to update my question to give more details.
I updated the link in my answer and it's a little faster now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.