3

使用敲除剑道绑定绑定 Telerik Kendo 网格时是否可以指定默认排序?

我正在像这样绑定网格:

kendoGrid: { data: grid.Rows, sortable: {allowUnsort: false,mode:'single'}, columns: grid.Columns} 

但是,我还没有找到指定默认排序的方法。标准剑道有一个sort:{field:"Col1",dir:"asc"}可以在数据源上指定的元素,但不清楚如何将其应用于kendoGrid绑定

默认剑道排序元素:http ://docs.telerik.com/kendo-ui/api/framework/datasource#sort-array--objectdefault

4

2 回答 2

6

The comments from the following answer gave me a clue:

What is the difference between the data and dataSource in knockout-kendo grid widget?

It seems like you can use data and dataSource in tandem if you want to specify this behavior:

kendoGrid: {dataSource:{sort:{field:'Col1',dir:'asc'}}, data: grid.Rows, sortable: {allowUnsort: false,mode:'single'}, columns: grid.Columns}
于 2014-04-30T17:21:35.400 回答
2

查看剑道论坛中的以下帖子。

http://www.telerik.com/forums/default-sort-for-kendo-grid-mvc

.DataSource(dataSource => dataSource
        .Ajax()
        .Sort(sort => sort.Add("City").Ascending()) // <-- initial sort expression
        .Read(read => read.Action("Index", "Home"))
    )
于 2014-04-30T18:26:22.777 回答