Skip to content

Commit

Permalink
Fix Piwik UI becomes very slow when having many rows
Browse files Browse the repository at this point in the history
PR for Piwik 2.x for #11308
  • Loading branch information
tsteur authored Feb 2, 2017
1 parent 17230c4 commit 1dd3dff
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugins/CoreHome/javascripts/dataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1dd3dff

Please sign in to comment.