Specify the default sort in the grid

Can I specify a default sort when using the knockout-kendo binding to snap the Telerik Kendo mesh?

I snap the grid as follows:

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

However, I did not find a way to specify the default sort. Standard Kendo has an element sort:{field:"Col1",dir:"asc"} , which can be specified in the data source, but it is unclear how this can be applied to the kendoGrid binding

Kendo default collation: http://docs.telerik.com/kendo-ui/api/framework/datasource#sort-array--objectdefault

+3
javascript kendo-grid knockout-kendo
Apr 30 '14 at 16:34
source share
2 answers

Comments from the following answer gave me the key:

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

It looks 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} 
+5
Apr 30 '14 at 17:21
source share

Check out the following post on kendo forums.

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")) ) 
+3
Apr 30 '14 at 18:26
source share



All Articles