PagedList.MVC中的Ajax分页使用部分页面

Yog*_*yal 21 asp.net-mvc pagination asp.net-ajax pagedlist

如果我不使用部分页面,PagedList.Mvc工作正常,但是当我使用带有ajax的部分页面加载网格时,分页存在问题.我在TroyGoode的支持下结束了https://github.com/TroyGoode/ PagedList/issues/26#issuecomment-6471793,但是为支持提供的链接不起作用.现在,我已经这样使用了

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

,它加载页面,但我需要ajaxically更改分页.我怎样才能做到这一点?

Yog*_*yal 34

使用PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing可以解决此问题.

@Html.PagedListPager(
    Model.MovieInforamtions, 
    page => Url.Action("GetMovieDatabase", new { page = page}),
    PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions(){  HttpMethod = "GET", UpdateTargetId = "movie_grid"})
)
Run Code Online (Sandbox Code Playgroud)


小智 6

另外,您可以使用jQuery Ajax进行以下操作。

https://github.com/ungleng/SimpleAjaxPagedListAndSearchMVC5