Kendo UI MVC,Grid View additional data using Data method not working

问题描述 投票:0回答:1

我在剃刀视图中有以下剑道网格:

@(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。 Chrome Network Inspector

我错过了什么?

编辑:

控制器:

[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);
}
razor kendo-ui kendo-grid kendo-asp.net-mvc
1个回答
0
投票

我发现了问题。问题是

POST
Read
方法的默认值。我添加了“
Type(HttpVerbs.Get)
”,它工作得很好。

.Read(read => read
    .Action("ReadInvoicePOs", "Invoice", new { invoiceID = ViewBag.InvoiceID })
    .Data("getInvoicePOsFilterData")
    .Type(HttpVerbs.Get)
)
© www.soinside.com 2019 - 2024. All rights reserved.