문제

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