From 1dd3dffca6cf256232331fb5183f649a7f3df30e Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Thu, 2 Feb 2017 14:39:35 +1300 Subject: [PATCH 1/2] Fix Piwik UI becomes very slow when having many rows PR for Piwik 2.x for #11308 --- plugins/CoreHome/javascripts/dataTable.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index bb892a636c5..aae62b3ad17 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -95,6 +95,7 @@ $.extend(DataTable.prototype, UIControl.prototype, { this.workingDivId = this._createDivId(); domElem.attr('id', this.workingDivId); + this.maxNumRowsToHandleEvents = 250; this.loadedSubDataTable = {}; this.isEmpty = $('.pk-emptyDataTable', domElem).length > 0; this.bindEventsAndApplyStyle(domElem); @@ -1502,8 +1503,13 @@ $.extend(DataTable.prototype, UIControl.prototype, { $nodes.off('click'); $nodes.on('click', toggleFooter); }, - + canHandleRowEvents: function (domElem) { + return domElem.find('table > tbody > tr').size() <= this.maxNumRowsToHandleEvents; + }, handleColumnHighlighting: function (domElem) { + if (!this.canHandleRowEvents(domElem)) { + return; + } var maxWidth = {}; var currentNthChild = null; @@ -1788,6 +1794,10 @@ $.extend(DataTable.prototype, UIControl.prototype, { // also used in action data table doHandleRowActions: function (trs) { + if (!trs || trs.length > this.maxNumRowsToHandleEvents) { + return; + } + var self = this; var merged = $.extend({}, self.param, self.props); From a3d828076c722e8ef62f185b75f75f4b8063dcfb Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Sat, 11 Feb 2017 15:09:55 +1300 Subject: [PATCH 2/2] disable some row features when there are more than 255 rows since tr from thead counts as well. --- plugins/CoreHome/javascripts/dataTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index aae62b3ad17..6050aa6937c 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -95,7 +95,7 @@ $.extend(DataTable.prototype, UIControl.prototype, { this.workingDivId = this._createDivId(); domElem.attr('id', this.workingDivId); - this.maxNumRowsToHandleEvents = 250; + this.maxNumRowsToHandleEvents = 255; this.loadedSubDataTable = {}; this.isEmpty = $('.pk-emptyDataTable', domElem).length > 0; this.bindEventsAndApplyStyle(domElem);