From 09f687223b81813fd3a0f4357d1ce9cd9f60d4ea Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 23 Jul 2015 18:15:24 +0530 Subject: [PATCH] If sort by field is missing, don't add it to order by --- .../public/js/frappe/views/reports/reportview.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/views/reports/reportview.js b/frappe/public/js/frappe/views/reports/reportview.js index cd2c365d60..72cb27132b 100644 --- a/frappe/public/js/frappe/views/reports/reportview.js +++ b/frappe/public/js/frappe/views/reports/reportview.js @@ -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) {