martijnboland / MvcPaging

ASP.NET MVC Paging HTML helper
https://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/
MIT License
290 stars 144 forks source link

Last page not showing if same as max number of pages #61

Closed vchalub closed 7 years ago

vchalub commented 7 years ago

Hi, I found an issue when I have the number of pages as same as the default (10) or what I set in the option MaxNrOfPages. The last page does not appear, unless I click on a page closer to the end. For example, if I have 10 pages on total e set MaxNrOfPages(9), at first it shows only 1 to 9. Then, if I click on page 7, it shows the pages 1 to 10.

To fix this issue for me, I changed the class Pager, method BuildPaginationModel. Where it says: if (end < pageCount - 1) { model.PaginationLinks.Add(new PaginationLink { Active = false, DisplayText = "...", IsSpacer = true }); } I changed to: if (end <= pageCount - 1) { model.PaginationLinks.Add(new PaginationLink { Active = false, DisplayText = "...", IsSpacer = true }); }

Then, it shows like this: 1 2 3 4 5 6 7 8 9 ... For me, this change was enough. Just letting you guys know.

Cheers,

Vanessa

bjuraga commented 7 years ago

The same issue can be replicated when the page size is set to 20, the page number is 1 to 3, total number of results is 105. MaxNrOfPages is set to 5 Expected display : [previous] 1 2 3 4 5 ... [next] Acctual display : [previous] 1 2 3 4 5 [next]

martijnboland commented 7 years ago

Fixed, thanks for the detailed report.