Kendo UI Grid local data source column sort by default

You are defining the sort line in the wrong place. You’re putting it as one of the grid’s properties, but it is (as you said) one of the datasource’s property.

Put it as a child of the datasource property:

$('#grid').kendoGrid({
    dataSource: {
        data: [{
            date: "Feb 13 2014",
            price: 5,
        }, {
            date: "Feb 15 2014",
            price: 7,
        }, {
            date: "Feb 12 2014",
            price: 6,
        }],
        sort: {
            field: "price",
            dir: "desc"
        }
    },
    height: 500,
    sortable: true,
    pageable: false,
    columns: [{
        field: "date",
        title: "Date"
    }, {
        field: "price",
        title: "Price",
    }],
});

If it still doesn’t work, I can provide a jsFiddle for you to work around with.

Leave a Comment

tech