Kendo Grid not sorting

2 posts, 1 answers
  1. Deej
    Deej avatar
    14 posts
    Member since:
    Oct 2013

    Posted 15 Oct 2013 Link to this post

    I have a grid that's pulling data from an array, and it just won't sort when it loads up. I can sort it by clicking the column header, but I need it initially sorted. No matter what I try, it always comes up unsorted. The first few entries in the Count column are 100, 222, 11, 441, 168, 15, 493, 11, 32, 24...
    $('#TopCalcsGrid').kendoGrid({
        dataSource: {
            data: topcalcs,
            schema: {
                model: {
                    fields: {
                        Name: { type: "string" },
                        Count: { type: "number" }
                    }
                }
            }
        },
        sortable: {
            allowUnsort: true
        },
        reorderable: true,
        resizable: true,
        columns: [{
            field: "Name",
            title: "Calculator"
        }, {
            field: "Count",
            title: "Count"
        }],
        sort: { field: "Count", dir: "desc" }
    });
  2. Answer
    Deej
    Deej avatar
    14 posts
    Member since:
    Oct 2013

    Posted 15 Oct 2013 Link to this post

    Turns out sort is a property of DataSource, not KendoGrid. Put the sort property inside the dataSource block and it works.
Back to Top