排序我使用一個類似於一個的WebGrid提到hereMVC3剃刀的WebGrid分頁和超過2000條記錄
@{
var grid = new WebGrid(canPage: true, rowsPerPage: ThisController.PageSize, canSort: true, ajaxUpdateContainerId: "grid");
grid.Bind(Model.Employees, rowCount: Model.TotalRecords, autoSortAndPage: false);
grid.Pager(WebGridPagerModes.All);
@grid.GetHtml(htmlAttributes: new { id="grid" },
columns: grid.Columns(
grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { EmployeeID = item.EmployeeID })),
grid.Column("FullName"),
grid.Column("Title")
));
}
但在我的情況下,我期待着2000多條記錄,我想加載僅50要在每個頁面上加載記錄,以便頁面加載速度更快。如何確保在頁面加載時只加載前50條記錄,並且當我的用戶單擊頁面2時我想加載下一組50條記錄等等。 任何你遇到了類似的話,請建議我一些示例代碼
好答案的行數。我想補充的唯一想法是你最終需要兩個數據庫查詢。一個獲取分頁數據(在本例中是5行)以及一個查詢來獲得正確設置分頁的總行數。 – Gromer 2012-07-30 18:04:02