d.lavysh
d.lavysh

Reputation: 1514

Kendo Grid. Razor Mode. Column Sorting

I'm using Kendo UI Grid in my current project. I found out that Sorting doesn't work if column has Template. In following solution fix only for javascript grid realization: http://www.kendoui.com/forums/kendo-ui-web/grid/row-template-sorting.aspx

How to achive sorting in Razor mode?

Example of column with template: columns.Bound(e => e.OrderNumber).Template(e => @Html.ActionLink(e.OrderNumber.ToString(), "Test", "Test"));

Upvotes: 0

Views: 991

Answers (1)

Petur Subev
Petur Subev

Reputation: 20233

Creating a Template for the column and/or using a RowTemplate should not affect the sorting support.

Here is an example via JavaScript (Razor outputs JavaScript at the end and should make no difference)

$("#grid").kendoGrid({
    dataSource: dataSource,
    pageable: true,
    sortable:true,
    rowTemplate:"foo #= ProductID#",
    height: 430,
    toolbar: ["create"],
    columns: [
        { field:"ProductName", title: "Product Name" },
        { field: "UnitPrice", title:"Unit Price", format: "{0:c}", width: "100px" },
        { field: "UnitsInStock", title:"Units In Stock", width: "100px" },
        { field: "Discontinued", width: "100px" },
        { command: ["edit", "destroy"], title: " ", width: "160px" }],
    editable: "popup"
});

Upvotes: 2

Related Questions