0

我正在尝试在我的 MVC 应用程序中使用剑道网格实现服务器端排序。但未显示排序选项。我已经仔细检查了我是否启用了所有必要的选项(使服务器对剑道网格数据源的排序为真,并使网格元素的可滚动为真)以执行此操作,但我仍然能够找到可排序的选项。下面是我的剑道网格代码

剑道网格脚本

var grid = $("#grid");
    grid.children().remove();
    grid.kendoGrid({
        columns: [{attributes:"",field:"",template:"${ResultFields[0].Value},title:"Column 1",width:"110px"},{attributes:"",field:"",template:"${ResultFields[1].Value},title:"Column 1",width:"110px"}],
        resizable: true,
        reorderable: true,
        scrollable: true,
        filterable: true,
        columnMenu: true,
        selectable: "row",
        selectable: "multiple",
        dataBound: function () { alert("Data Bound"); },
        dataSource: {
            transport: {
                read: {
                    url: '@Url.Action("Index", "KendoServerSideSorting")',
                    type: "GET",
                    dataType: "json",
                    traditional: true,
                    data: {
                        itemTypeId: 1,
                        where: values,
                        orderBy: ["", "", ""],
                    },
                },
            },
            schema: {
                data: "Items",
                total: "TotalItems",
            },
            serverPaging: true,
            pageSize: 10,
            error: function (e) {
                alert(e.errors);
            }
        },
        pageable: {
            pageSize: 10,
            input: true,
            pageSizes: [10, 20, 30, 50, 100, 250],
        },
        change: function () { alert("Change event"); },
    })

控制器动作看起来像这样

public JsonResult Search(int itemTypeId, int skip, int take, string[] where, string[] orderBy)
    {
        var v = Kernel.Get<IItemSearch>().Search(itemTypeId, skip, take, where, orderBy);
        return Json(v, JsonRequestBehavior.AllowGet);
    }

*谁能帮我解决这个问题。*

4

1 回答 1

0

You can use the helper functionality from KendoGridBinderEx to parse all the commands (like filter and sort) and do the filtering and sorting at the server-side automatically using DynamicLinq.

See this project : https://github.com/StefH/KendoGridBinderEx for some examples.
Also available as NuGet package : https://www.nuget.org/packages/KendoGridBinderEx/

于 2015-01-16T07:07:16.203 回答