Merge pull request #1216 from anandpdoshi/reportview-sort-fix

If sort by field is missing, don't add it to order by
This commit is contained in:
Anand Doshi 2015-07-24 12:21:15 +05:30
commit 5294f1b002

View file

@ -187,17 +187,21 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
},
get_order_by: function() {
var order_by = [];
// first
var order_by = this.get_selected_table_and_column(this.sort_by_select)
+ ' ' + this.sort_order_select.val();
var sort_by_select = this.get_selected_table_and_column(this.sort_by_select);
if (sort_by_select) {
order_by.push(sort_by_select + " " + this.sort_order_select.val());
}
// second
if(this.sort_by_next_select.val()) {
order_by += ', ' + this.get_selected_table_and_column(this.sort_by_next_select)
+ ' ' + this.sort_order_next_select.val();
order_by.push(this.get_selected_table_and_column(this.sort_by_next_select)
+ ' ' + this.sort_order_next_select.val());
}
return order_by;
return order_by.join(", ");
},
get_selected_table_and_column: function(select) {