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
Ajax Pagination in PagedList.MVC using partial Page
提问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 来执行此操作,如下例所示。
回答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才能工作,如果您不添加此项目,则不起作用

