Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting a Column by Default (on load) Using Dojo Dgrid

When loading a dgrid from a dojo store, is there a way to specify a column to be sorted by default.

Say I have 2 columns, Name and Email, I want the name column sorted by default when the grid is first loaded. What I want is the equivalent of the user clicking on the 'Name' header (complete with the sort arrow indicating the sort direction).

Thanks, John

like image 739
JohnB Avatar asked Apr 30 '13 06:04

JohnB


1 Answers

You can do something like this :

var mygrid = new OnDemandGrid({
    store : someStore,
    queryOptions: {
        sort: [{ attribute: "name" }]
    }
    // rest of your grid properties
}, "someNode");
like image 113
Philippe Avatar answered Nov 15 '22 10:11

Philippe