Telerik UI for Windows 8 HTML

The DataSource component can perform sorting when bound to local or remote data. Using the sort property you can pass one or multiple sort expressions. There is also an option to use the DataSource to pass parameters for sorting on the server by enabling server sorting and sending the required parameters.

Define Sort Expressions

The sort property is set when sorting needs to be applied to the data. The property can contain either an object with format { field: "fieldName", dir: "asc" }, or an array of objects with the same format for specifying multiple sort expressions. The meaning of the sort property options is as follows:

  • field: The name of the field that needs to be sorted.

  • dir: The sort direction. Accepted values are: "asc" for ascending and "desc" for descending.

DataSource Sorting Setup Copy imageCopy
var myDataSource = new Telerik.Data.DataSource({
    transport: {
        read: {
            url: "",
            dataType: "json"
    schema: {
        data: "value"
    sort: [
        { field: "LastName", dir: "desc" },
        { field: "FirstName", dir: "asc" }
}); () {
    //data is sorted
    var data = myDataSource.view;

Server Sorting

When binding to remote data, the serverSorting Boolean property can be used to specify how data is sorted. If set to true, the DataSource sends the sort expressions to the remote endpoint and expects the sorted data back. Note that based on the scenario, you may need to use the transport.parameterMap property to modify the array of expressions sent to the remote endpoint. For more information, see the Configuring Remote Binding article. The default value of the serverSorting property is false, meaning data is sorted locally, by the DataSource itself.