// called after a sort change occurs within the column picker
cpSortHandler : function(fields) {
- console.log("AutoGrod cpSortHandler(): " + fields);
+ console.log("AutoGrod cpSortHandler(): " + js2JSON(fields));
// user-defined sort handler
if (this.onSortChange) {
this.onSortChange(fields)
} else {
if (!this.cachedQueryOpts)
this.cachedQueryOpts = {};
+ var order_by = '';
+ dojo.forEach(fields, function(f) {
+ if (order_by) order_by += ',';
+ order_by += f.field + ' ' + f.direction
+ });
this.cachedQueryOpts.order_by = {};
- this.cachedQueryOpts.order_by[this.fmClass] = fields.join(',');
+ this.cachedQueryOpts.order_by[this.fmClass] = order_by;
this.refresh();
}
},
"<th width='23%'>Auto Width</th><th width='23%'>Sort Priority</th></tr></thead>" +
"<tbody />"});
- var tDiv = dojo.create('div', {style : 'height:400px; overflow-y:auto'});
+ var tDiv = dojo.create('div', {style : 'height:400px; overflow-y:auto;'});
tDiv.appendChild(table);
var bDiv = dojo.create('div', {style : 'text-align:right; width:100%;',
innerHTML : "<span name='cancel_button'></span><span name='save_button'></span>"});
+
+ var textDiv = dojo.create('div', {style : 'padding:5px; margin-top:5px; border-top:1px solid #333',
+ innerHTML :
+ "<i>A Sort Priority of '0' means no sorting is applied.<br/>" +
+ "<i>Apply a negative Sort Priority for descending sort."});
var wrapper = dojo.create('div');
wrapper.appendChild(tDiv);
+ wrapper.appendChild(textDiv);
wrapper.appendChild(bDiv);
dialog.containerNode.appendChild(wrapper);
// this must be added after its parent node is inserted into the DOM.
var ns = new dijit.form.NumberSpinner(
- { constraints : {min : 0, places : 0},
+ { constraints : {places : 0},
value : cell._sort || 0,
style : 'width:4em',
name : 'sort'
// extract cells that have sorting applied, order lowest to highest
buildSortList : function() {
var sortList = this.cells.filter(
- function(cella) { return cella._sort > 0 }
+ function(cella) { return cella._sort != 0 }
).sort(
function(a, b) {
- if (a._sort < b._sort) return -1;
+ if (Math.abs(a._sort) < Math.abs(b._sort)) return -1;
return 1;
}
);
- return sortList.map(function(f){return f.field});
+ return sortList.map(function(f){
+ var dir = f._sort < 0 ? 'desc' : 'asc';
+ return {field : f.field, direction : dir};
+ });
},
// save me as a user setting