【发布时间】:2023-03-12 14:23:01
【问题描述】:
我正在尝试使用 Kendo 显示网格并希望添加服务器端分页。这就是我的视图的样子
@(Html.Kendo().Grid<Models.Employee>()
.Name("empGrid")
.Columns(column =>
{
column.Bound(emp => emp.Tickets).Title("Tickets").Filterable(false).Sortable(false)
.ClientTemplate("<div style='display:flex;align-items:center;'> " +
" #= getLateTicketIcon(DueDate) # "
"</div>").Width(100);
column.Bound(emp => emp.EmpID).Hidden();
column.Bound(emp => emp.DeptID).Hidden();
column.Bound(emp => emp.Name).Title("Name#").Width(100);
column.Bound(emp => emp.TicketNumber).Width(150).ClientTemplate("#= getEempTickets(EmpID, DeptID) # ");
column.Bound(emp => emp.DueDate).Width(150)
.ClientTemplate("#: DueDate === null ? '' : kendo.toString(getDateAsUTC(kendo.parseDate(DueDate)), 'MM/dd/yyyy') #");
})
.NoRecords("There are no records to display")
.Sortable()
.Scrollable(scrollable => scrollable.Height("auto"))
.Pageable(pager => pager
.PageSizes(new[] { 10, 25, 50, 100, 200 })
.Refresh(true)
.Input(true))
.Filterable()
.Resizable(resizable => resizable.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.Excel(ex =>
{
ex.AllPages(true);
ex.Filterable(true);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(50)
.ServerOperation(true)
.Read(read => read.Action("GetTickets", "Employee").Data("readFromServerWithParameters").Type(HttpVerbs.Get)))
.Events(ev => ev.DataBound("currentGridDataBound"))
.AutoBind(false))
控制器看起来像,我面临的问题是我在 UI 上选择的页码是什么,页码始终为 1。
[HttpGet]
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public ActionResult GetTickets([DataSourceRequest] DataSourceRequest request, long? empID, string[] searchOptions)
{
List<Employee> results = repo.GetTickets(empID, searchOptions,request.Page,request.PageSize);
JsonResult resultJson = Json(results.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
resultJson.MaxJsonLength = int.MaxValue;
return resultJson;
}
【问题讨论】:
-
你能贴一张网格的截图吗?这将有助于其他人更好地理解问题。
标签: asp.net-mvc model-view-controller kendo-ui kendo-grid kendo-asp.net-mvc