26

PagedList.Mvc is working fine if I do not use partial page but when I use partial page with ajax to load the grid then there is problem in pagination.and I ended with the support from TroyGoode https://github.com/TroyGoode/PagedList/issues/26#issuecomment-6471793, But link provided for the support is not working. Right now, I have used like this

@Html.PagedListPager((IPagedList)Model.MovieInforamtions, page => Url.Action("GetMovieDatabase", new { page }))

, which loads the page but I need to change the pagination ajaxically. How can I achieve this?

Yogendra Paudyal
  • 1,387
  • 1
  • 12
  • 17

4 Answers4

47

This issue is solved by using PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing.

@Html.PagedListPager(
    Model.MovieInforamtions, 
    page => Url.Action("GetMovieDatabase", new { page = page}),
    PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions(){  HttpMethod = "GET", UpdateTargetId = "movie_grid"})
)
Chuck D
  • 1,629
  • 2
  • 16
  • 32
Yogendra Paudyal
  • 1,387
  • 1
  • 12
  • 17
  • Can you post the link to your project if present in GitHub or somewhere? – Rockstart Jun 20 '14 at 20:29
  • what if we want to **bookmark** example: page 2 , as said [here](http://stackoverflow.com/a/20824965/2218697) in address bar query strings are not present on Ajax GET, is there any solution using ajax history [plugins](http://stackoverflow.com/questions/3242644/the-best-ajax-history-and-bookmark-plugin-currently-available)? – Shaiju T Feb 22 '16 at 09:52
  • This shows a blank page if user login session is timeout. How the ajax request response can be intercepted here to check the status? – InTheWorldOfCodingApplications Sep 15 '16 at 15:30
6

Alternatively , you can use jQuery Ajax to do so as below example.

https://github.com/ungleng/SimpleAjaxPagedListAndSearchMVC5

LENG UNG
  • 473
  • 6
  • 5
4

The code works, but you need to add the reference to jquery-unobtrusive-ajax.min.js into your main view or partial.

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
-3

People This Code dosent Work You Have To Add Microsoft.Jauery.unobtrusive-ajax To Work If You Don`t Add This Item Dose not Work

Aurasphere
  • 3,841
  • 12
  • 44
  • 71