razorkendo-uikendo-gridkendo-asp.net-mvc

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


I have the following Kendo grid in a razor view:

@(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()
)

And the getInvoicePOsFilterData JavaScript function:

<script>
    function getInvoicePOsFilterData() {
        return {
            pONumber: $('#PONumber').val(),
            vendorId: $('#VendorId').val(),
            clientId: $('#ClientId').val()
        };
    }
</script>

When I look at the request in the Chrome Network Inspector, nothing is being sent for the data InvoiceId, which is the routeData. Chrome Network Inspector

What am I missing?

Edit:

The controller:

[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);
}

Solution

  • I found the problem. The problem was that POST is default for the Read method. I added "Type(HttpVerbs.Get)", and it worked just fine.

    .Read(read => read
        .Action("ReadInvoicePOs", "Invoice", new { invoiceID = ViewBag.InvoiceID })
        .Data("getInvoicePOsFilterData")
        .Type(HttpVerbs.Get)
    )