我在剃刀视图中有以下剑道网格:
@(Html.Kendo().Grid<PO>()
.Name("manualMatchGrid")
.Columns(columns =>
{
BindFields(columns);
})
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.Pageable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Model(model =>
{
model.Id(l => l.Id);
})
.Read(read => read
.Action("ReadInvoicePOs", "Invoice", new { invoiceID = ViewBag.InvoiceID })
.Data("getInvoicePOsFilterData")
)
)
.Pageable()
.Navigatable()
)
以及
getInvoicePOsFilterData
JavaScript 函数:
<script>
function getInvoicePOsFilterData() {
return {
pONumber: $('#PONumber').val(),
vendorId: $('#VendorId').val(),
clientId: $('#ClientId').val()
};
}
</script>
当我在 Chrome 网络检查器中查看请求时,没有为数据
InvoiceId
发送任何内容,即 routeData。
我错过了什么?
编辑:
控制器:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult ReadInvoicePOs([DataSourceRequest]DataSourceRequest request,
int invoiceId, string pONumber, int? vendorId, int clientId)
{
var pOs = dynamicPOManager.GetPOs(invoiceId, clientId, pONumber);
DataSourceResult result = pOs.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
我发现了问题。问题是
POST
是 Read
方法的默认值。我添加了“Type(HttpVerbs.Get)
”,它工作得很好。
.Read(read => read
.Action("ReadInvoicePOs", "Invoice", new { invoiceID = ViewBag.InvoiceID })
.Data("getInvoicePOsFilterData")
.Type(HttpVerbs.Get)
)