0
我正在使用剑道网格服务器端分页。我在数据库端对数据进行排序和提取,这给我提供了只有pagesize数量的记录。我也从后端本身获得了全部记录的数量。我只想将这些数据绑定到kendo网格上,根据返回的计数显示页码。kendo ui grid完成服务器端分页和设置总数
即对于每一个下一个页面请求,我只返回pagesize(例如15)个记录总数的记录。以下是我的剑道网格代码。请帮助我绑定这些记录并根据总数显示页码。
@(Html.Kendo().Grid(Model.InvoiceList)
.Name("InvoiceGrid")
.Columns(columns =>
{
columns.Bound(p => p.CompanyName).Title("Company Name").Width(80);
columns.Bound(p => p.Account).Title("Account").Width(60);
columns.Bound(p => p.MerchantNumber).Title("Merchant No.").Width(60);
columns.Bound(p => p.InvoiceAmount).Title("Invoice Amount").Width(60);
columns.Bound(p => p.ReferralPercentage).Title("Referral %").Width(60);
columns.Bound(p => p.ReferralCommission).Title("Referral Com.").Width(60);
columns.Bound(p => p.DeveloperPercentage).Title("Developer %").Width(60);
columns.Bound(p => p.DeveloperCommission).Title("Developer Com.").Width(60);
})
.Pageable(
)
.Sortable()
.Filterable(filterable => filterable
.Extra(false)
)
.DataSource(dataSource => dataSource
.Ajax()
.Batch(false)
.PageSize(15)
.ServerOperation(true)
.Read(read => read.Action("Index", "Invoice")
).Total(Model.count)
)
)
我用来获取记录的服务器端代码如下。
public async Task<ActionResult> IndexAsync(int pageNo=0,int numberOfRecord=15)
{
//InvoicePaging has invoice list of 15 records and count = 400
InvoicePaging ip = await InvoiceDAL<FileRecord>.getAllInvoices("SProcGetInvoiceList", pageNo, numberOfRecord);
return View("InvoiceList",ip);
}
发票分页类 -
public class InvoicePaging
{
[JsonProperty(PropertyName = "InvoiceList")]
public List<Invoice> InvoiceList { get; set; }
[JsonProperty(PropertyName = "count")]
public int count { get; set; }
}