We are trying to use Kendo DataSource object to create requests to our custom ActionResult.

The ActionResult receives the same type of parameters as KendoGrid is sending.

We don't want to use KendoGrid to display the data, we just need the filtering functionality of KendoDataSource.

enter image description here

public ActionResult Search([DataSourceRequest] DataSourceRequest request)
{
    var dbItems = _db.DataItems.ToDataSourceResult(request).Data;
    return Json(dbItems, JsonRequestBehavior.AllowGet);
}

var dataSource = new kendo.data.DataSource({
    serverSorting: true,
    sort: { field: "DataItemName", dir: "desc" },
    transport: {
        read: {
            type: "GET",
            url: "/Home/Search"
        }
    },
});
dataSource.read();

What are we doing wrong?

PS: Setting the method to POST makes no difference

没有正确的解决方案

其他提示

Changing the DataSource configuration to this it worked:

Also the ActionResult is of type POST

var dataSource = new kendo.data.DataSource({
    serverSorting: true,
    serverFiltering: true,
    serverGrouping: true,
    serverPaging: true,
    type: "aspnetmvc-ajax",
    sort: { field: "DataItemName", dir: "desc" },
    transport: {
        read: {
            prefix: "",
            url: "/Home/Search"
        }
    },
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top