Sort a default column (at boot) Using Dojo Dgrid

When loading dgrid from the dojo repository, there is a way to specify a default sort column.

Let's say I have 2 columns, a name and an email address, I want the name column to sort by default when the grid was loaded first. What I want is equivalent to the user clicking on the "Name" heading (complete with a sort arrow indicating the direction of the sort).

Thanks, John

+4
source share
2 answers

You can do something like this:

var mygrid = new OnDemandGrid({ store : someStore, queryOptions: { sort: [{ attribute: "name" }] } // rest of your grid properties }, "someNode"); 
+9
source

dgrid 1.1.0 - set default / default sort order

  var TrackableRest = declare([Rest, SimpleQuery, Trackable]); var store = new TrackableRest({target: apiUrl, useRangeHeaders: true, idProperty: 'id'}); var grid = new (declare([OnDemandGrid, Selection, Editor]))({ collection: store, sort: [{"property":"name", "descending": false}], className: "dgrid-autoheight", columns: { id: { label: core.id }, category_text: { label: asset.category }, name: { label: asset.model, }, 
-1
source

All Articles