سؤال

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