클라이언트 쪽 페이징을 피하기 위해 컨트롤러에서 검도 그리드의 페이지 인덱스를 설정하려고합니다. 클라이언트 쪽 페이징을 사용하면 첫 페이지의 레코드 외에 다른 레코드가 표시되지 않습니다. 컨트롤러에서 데이터를 호출 할 때 페이지에 필요한 10 개의 레코드 만 반환합니다. 데이터 호출에는 Skip() 및 Take() 함수가 포함되어 전체 그리드를로드하는 대신 서버에서 필요로하는 것을 반환합니다.Kendo UI 그리드 페이지 인덱스를 MVC 컨트롤러로 설정하십시오.
.cshtml
@(Html.Kendo().Grid<Reckon.Service.Payroll.Data.DTO.EmployeeDto>()
.Name("EmployeeGrid")
.Columns(cols =>
{
cols.Bound(emp => emp.Id).Title("ID").Hidden();
cols.Bound(emp => emp.EmployeeNumber).Title("Employee ID").Width(100);
cols.Bound(emp => emp.IsPayRunReady).Title("Status").Width(10).ClientTemplate("<span title='This employee is #= IsPayRunReady ? '': 'not '#payrun ready.' class='#= IsPayRunReady ? 'okICN-small' : 'alertICN-small'#'>#= IsPayRunReady ? '': 'Not' # #= IsPayRunReady ? 'P':'p'#ayrun ready</span>");
cols.Bound(emp => emp.FirstName).Title("First Name").Width(100);
cols.Bound(emp => emp.LastName).Title("Last Name").Width(100);
cols.Bound(emp => emp.DateOfBirth).Title("DOB").Format("{0:dd/MM/yyyy}").Width(100);
cols.Template(@<text></text>).ClientTemplate("<a href='" + Url.Action("EmployeeDetailEdit", "EmployeeDetail") + "/#=Id#'>Edit</a>").Width(50);
cols.Template(@<text></text>).ClientTemplate("<a href='" + Url.Action("EmployeeDetailRead", "EmployeeDetailRead") + "/#=Id#'>View</a>").Width(50);
cols.Template(@<text></text>).ClientTemplate("<a class='k-button xxx' tag='#=Id#'>Delete</a>").Width(50);
})
.Pageable(pageable => pageable.ButtonCount(5))
.Sortable(sortable => sortable.AllowUnsort(false))
.Filterable()
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.Navigatable()
.Events(evt => evt.DataBound("afterGridLoaded"))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(10)
.ServerOperation(false)
.Model(model =>
{
model.Id(emp => emp.Id);
})
.Read(read => read.Action("EmployeeListPerPage", "EmployeeDetail"))
)
)
.cs
public ActionResult EmployeeListPerPage([DataSourceRequest] DataSourceRequest request)
{
Dispose();
EmployeeListRequest empList = new EmployeeListRequest();
empList.PageNum = request.Page;
empList.PageSize = request.PageSize;
//empList.OrderBy = null; //request.Sorts.Any() ? "EmployeeNumber" : request.Sorts[0].Member;
var dataSource = _payrollService.GetEmployeeListPerPage(empList);
var model = new EmployeeListModel(dataSource);
DataSourceResult result = model.Employees.ToDataSourceResult(request);
result.Total = dataSource.Total;
// Set the Page index here
return Json(result, JsonRequestBehavior.AllowGet);
}
클라이언트 측 페이징을 이용하면, 첫 번째 페이지로 리턴 데이터를 설정하고 복귀 클라이언트 측 페이징을 수행 결과가 없습니다.
할 수 있습니까? 도움을 주시면 대단히 감사하겠습니다. 당신이 엔티티 프레임 워크, 검도/EF 페이징을 돌볼 수 있도록 이에 대한 컨트롤러를 변경 사용하고 있기 때문에
어떤 이유로 당신은 검도의 페이징을 사용하고 싶지 않습니까? –
검도 페이징은 클라이언트 쪽이며 서버 쪽에서 데이터가 반환되면 현재 페이지에 필요한 10 개의 레코드 만 반환합니다. 레코드는 첫 번째 10 레코드로 그리드에 바인딩되며 첫 페이지 이외의 다른 페이지를 클릭하면 다른 레코드가 표시되지 않습니다. 그래서 모든 데이터를 그리드로 반환하지 않고 현재 선택한 페이지에 필요한 데이터 만 반환하기 때문에 검도 페이징을 사용하고 싶지 않습니다. –
왜 이렇게하려고하는지 이해가 안됩니다.'empList.PageNum = request.Page;'Kendo가 자동으로 수행하는 작업과 본질적으로 다른 작업을하고 있습니다. 쿼리 문자열을 통해 페이지를 방문하면 적절한 페이지가 반환됩니다. –