asp.net-mvc PagedList.MVC 中的 Ajax 分页使用部分页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17336165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 02:58:30  来源:igfitidea点击:

Ajax Pagination in PagedList.MVC using partial Page

asp.net-mvcpaginationasp.net-ajaxpagedlist

提问by Yogendra Paudyal

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

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

@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?

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

回答by Yogendra Paudyal

This issue is solved by using PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing.

这个问题是通过使用 PagedListRenderOptions.EnableUnobtrusiveAjaxReplaceing 解决的。

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

回答by LENG UNG

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

或者,您可以使用 jQuery Ajax 来执行此操作,如下例所示。

https://github.com/ungleng/SimpleAjaxPagedListAndSearchMVC5

https://github.com/ungleng/SimpleAjaxPagedListAndSearchMVC5

回答by pape moussa ndiaye

The code works, but you need to add the reference to jquery-unobtrusive-ajax.min.jsinto your mainview or partial.

该代码有效,但您需要将jquery-unobtrusive-ajax.min.js的引用添加到您的main视图或partial.

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

回答by user8805778

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

人员此代码不工作,您必须添加Microsoft.Jauery.unobtrusive-ajax才能工作,如果您不添加此项目,则不起作用