从 dojo 商店加载 dgrid 时,有没有办法指定要默认排序的列。
假设我有 2 列,名称和电子邮件,我希望在第一次加载网格时默认对名称列进行排序。我想要的是相当于用户单击“名称”标题(带有指示排序方向的排序箭头)。
谢谢,约翰
你可以这样做:
var mygrid = new OnDemandGrid({
store : someStore,
queryOptions: {
sort: [{ attribute: "name" }]
}
// rest of your grid properties
}, "someNode");
dgrid 1.1.0 - 设置初始/默认排序顺序
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,
},