0
votes

I am trying to implement server side sorting with kendo grid in my MVC application. but sorting option is not showing. i have double checked that i have enabled all the necessary option (made the serversorting to true to the the kendo grid data source and made the scrollable to true to the grid element) to do this but still i am able to find the sortable option. below is my kendo grid code

Kendo Grid Script

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"); },
    })

Controller Action will look like this

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

*Can anyone help me to resolve this issue. *

1
i found this to be very helpful implementing the server side sorting , paging and even multi-column filtering. its from Telerik. HTHMenahem
Shouldn't the JS object used to initialize Kendo have property sortable as shown here: demos.telerik.com/kendo-ui/web/grid/sorting.html ?SOReader
you could store the kendo grid data in an observable (either a kendo observable or a knockout observable, for example) and pass it through razor to be parsed server-side. just a thought.Adam R. Turner

1 Answers

0
votes

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/