From 3d04d1501436a74adf587b97ec9c48450a9fd153 Mon Sep 17 00:00:00 2001
From: diosmosis <benaka@piwik.pro>
Date: Sat, 20 Sep 2014 21:23:51 -0700
Subject: [PATCH] Refs #6078, fix regression in last commit and only send one
 request to save viewdatatable params when un-pivoting.

---
 plugins/CoreHome/javascripts/dataTable.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js
index 6a42e592ae..205ec70023 100644
--- a/plugins/CoreHome/javascripts/dataTable.js
+++ b/plugins/CoreHome/javascripts/dataTable.js
@@ -576,7 +576,7 @@ $.extend(DataTable.prototype, UIControl.prototype, {
 
             // we change the style of the column currently used as sort column
             // adding an image and the class columnSorted to the TD
-            $('.thDIV', domElem).filter(function () { return $(this).text() == self.param.filter_sort_column; }).parent()
+            $('th', domElem).filter(function () { return $(this).attr('id') == self.param.filter_sort_column; })
                 .addClass('columnSorted')
                 .prepend('<div class="sortIconContainer sortIconContainer' + ImageSortClass + ' ' + imageSortClassType + '"><span class="sortIcon" width="' + imageSortWidth + '" height="' + imageSortHeight + '" /></div>');
         }
@@ -1183,15 +1183,15 @@ $.extend(DataTable.prototype, UIControl.prototype, {
             return function () {
                 close();
                 if (setParamCallback) {
-                    setParamCallback();
+                    var data = setParamCallback();
                 } else {
                     self.param[paramName] = (1 - self.param[paramName]) + '';
+                    var data = {};
                 }
                 self.param.filter_offset = 0;
                 delete self.param.totalRows;
                 if (callbackAfterToggle) callbackAfterToggle();
                 self.reloadAjaxDataTable(true, callbackSuccess);
-                var data = {};
                 data[paramName] = self.param[paramName];
                 self.notifyWidgetParametersChange(domElem, data);
             };
@@ -1287,7 +1287,7 @@ $.extend(DataTable.prototype, UIControl.prototype, {
 
                 // remove sorting so it will default to first column in table
                 self.param.filter_sort_column = '';
-                self.notifyWidgetParametersChange(domElem, {filter_sort_column: ''});
+                return {filter_sort_column: ''};
             }));
 
         // handle highlighted icon
-- 
GitLab