null, this.columnPersistKey, this);
this.columnPicker.onLoad = dojo.hitch(
this, function(opts) { this._finishStartup(opts.sortFields) });
+
+ this.columnPicker.onSortChange = dojo.hitch(this,
+ /* directly after, this.update() is called by the
+ column picker, causing a re-fetch */
+ function(fields) {
+ this.store.baseSort = this._mapCPSortFields(fields)
+ }
+ );
+
this.columnPicker.load();
}
this.inherited(arguments);
},
- "_finishStartup": function() {
+ /* Maps ColumnPicker sort fields to the correct format.
+ If no sort fields specified, falls back to defaultSort */
+ "_mapCPSortFields": function(sortFields) {
+ var sort = this.defaultSort;
+ if (sortFields.length) {
+ sort = sortFields.map(function(f) {
+ a = {};
+ a[f.field] = f.direction;
+ return a;
+ });
+ }
+ return sort;
+ },
+
+ "_finishStartup": function(sortFields) {
- this.setStore( /* this exact method chosen intentionally */
+ this.setStore(
new openils.FlattenerStore({
"fmClass": this.fmClass,
"fmIdentifier": this.fmIdentifier,
"mapClause": (this.mapClause ||
this._cleanMapForStore(this._generateMap())),
"baseSort": this.baseSort,
- "defaultSort": this.defaultSort
+ "defaultSort": this._mapCPSortFields(sortFields)
}), this.query
);