From: Bill Erickson Date: Fri, 30 Mar 2012 18:00:36 +0000 (-0400) Subject: column picker onSortChange support added to flattener grid X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e392780a0840ee6eda70a4dcca0be8ae3ba8a282;p=evergreen%2Fequinox.git column picker onSortChange support added to flattener grid Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js index 1d7ca1f836..ae98d26a4e 100644 --- a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js @@ -214,22 +214,45 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) { 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 );