Ajax Pagination in PagedList.MVC using partial Page
Asked Answered
S

4

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?

Sec answered 27/6, 2013 at 6:38 Comment(0)
S
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"})
)
Sec answered 30/12, 2013 at 11:42 Comment(3)
Can you post the link to your project if present in GitHub or somewhere?Psoriasis
what if we want to bookmark example: page 2 , as said here in address bar query strings are not present on Ajax GET, is there any solution using ajax history plugins?Hotbox
This shows a blank page if user login session is timeout. How the ajax request response can be intercepted here to check the status?Coerce
S
6

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

https://github.com/ungleng/SimpleAjaxPagedListAndSearchMVC5

Suppuration answered 30/3, 2015 at 0:16 Comment(0)
C
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>
Coppersmith answered 8/5, 2019 at 13:51 Comment(0)
C
-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

Clingfish answered 20/10, 2017 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.