我希望分页以异步方式发生,但整个页面会在选择页面时重新加载。任何人都可以告诉我如何使分页异步发生?
这是代码。
@Html.PagedListPager(listData, page => Url.Action("ViewOnMap", new { search, Beds, Baths, minprize, maxprize, page, IsSearch, SearchFilterBy }),PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { HttpMethod="GET", UpdateTargetId= "DivPropertyOnMap" }))
答案 0 :(得分:0)
你为什么不用这个。你可以使用这样的东西。
https://www.nuget.org/packages/PagedList
public IPagedList<listData> getdata(int? Page, int? pageIndex)
{
...
return data.OrderByDescending(x => x.OnSave).ToPagedList(Page ?? 1, pageIndex ?? 10);
}
控制器
public ActionResult List(datamodel model)
{
var dataModel = new getdata(model.Page, 10);
return View("_dataList", dataModel );
}
Razor list.cshtml
<div id="listdata">
@Html.Partial("_List", @Model)
</div>
_list_cshtml
@model youdatemodel
@using PagedList;
@using PagedList.Mvc;
<ul>
@foreach (var item in Model.dataModel)
{
<li>
@item.dataitem;
</il>
}
</ul>
@Html.PagedListPager(Model.modeldata, page => Url.Action("List", new RouteValueDictionary
{
{
"Page",page
}
}), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions { UpdateTargetId = "listdata" }))