とPagedList.Mvc
パッケージをNuGet
経由でインストールしました。それから私は方法でそれを使用:コントローラ内部のコードでPagedListが正しくレンダリングされなかった
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Employee>
@{
ViewBag.Title = "ListEmployees";
}
<h3>All Employees (@ViewBag.TotalEmployees)</h3>
@if(Model.Count > 0)
{
foreach(var item in Model)
{
Html.RenderPartial("Employee.Card", item);
}
@Html.PagedListPager((IPagedList)Model, page => Url.Action("List", new { page = page }), PagedListRenderOptions.Minimal)
}
else
{
@: no records were found. Sorry
}
:
public class EmployeeController : Controller
{
private IRepository<Employee> repository;
private Int32 PageSize = 10;
public EmployeeController(IRepository<Employee> repository)
{
this.repository = repository;
}
public ActionResult List(Int32? page)
{
var set = repository.Get();
ViewBag.TotalEmployees = set.Count();
return View(set.ToPagedList(page ?? 1, PageSize));
}
}
は、結果としてunstyled順不同リストを持っているために、この正常です。そして、どのようにして私のカスタムスタイリングをページャーに適用するのですか?
ありがとうございます!
私は 'next/prev'リンクが無効になるように1ページしかありませんでした。それが原因だと思う?しかし、私が今得ているのは、スタイリングのない単純で無条件のリストです。それは正常な動作ですか、私は自分のスタイルを適用すべきですか? – lexeme
これは、pagedlist.cssファイルが含まれていない(または自分のスタイルになっている) – Troy