From 0f3a1660ff2e56a04d2c3b14c19d35b03b997200 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 26 Nov 2019 11:59:24 -0700 Subject: [PATCH] Api: Nextmatch - Do not generate DOM nodes for hidden columns --- api/js/etemplate/et2_dataview.js | 7 +++-- .../et2_dataview_view_rowProvider.js | 7 +++-- api/js/etemplate/et2_extension_nextmatch.js | 8 ++++-- .../et2_extension_nextmatch_rowProvider.js | 28 +++++++++++++++---- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/api/js/etemplate/et2_dataview.js b/api/js/etemplate/et2_dataview.js index 07ceeea7bc..69ba87bddd 100644 --- a/api/js/etemplate/et2_dataview.js +++ b/api/js/etemplate/et2_dataview.js @@ -493,10 +493,13 @@ var et2_dataview = (function(){ "use strict"; return Class.extend({ */ _buildGrid: function() { // Create the collection of column ids - var colIds = new Array(this.columns.length); + var colIds = new Array(); for (var i = 0; i < this.columns.length; i++) { - colIds[i] = this.columns[i].id; + if(this.columns[i].visible) + { + colIds[i] = this.columns[i].id; + } } // Create the row provider diff --git a/api/js/etemplate/et2_dataview_view_rowProvider.js b/api/js/etemplate/et2_dataview_view_rowProvider.js index e50e1336b7..55e3485822 100644 --- a/api/js/etemplate/et2_dataview_view_rowProvider.js +++ b/api/js/etemplate/et2_dataview_view_rowProvider.js @@ -100,13 +100,14 @@ var et2_dataview_rowProvider = (function(){ "use strict"; return Class.extend( var tr = jQuery(document.createElement("tr")); // Append a td for each column - for (var i = 0; i < this._columnIds.length; i++) + for (var column of this._columnIds) { + if(!column) continue; var td = jQuery(document.createElement("td")) - .addClass(this._outerId + "_td_" + this._columnIds[i]) + .addClass(this._outerId + "_td_" + column) .appendTo(tr); var div = jQuery(document.createElement("div")) - .addClass(this._outerId + "_div_" + this._columnIds[i]) + .addClass(this._outerId + "_div_" + column) .addClass("innerContainer") .appendTo(td); } diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index ce28b92a2a..eb8bea3bb7 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -1203,14 +1203,18 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ }, _parseDataRow: function(_row, _rowData, _colData) { - var columnWidgets = new Array(this.columns.length); + var columnWidgets = new Array(); _row.sort(function(a,b) { return a.colData.order - b.colData.order; }); - for (var x = 0; x < columnWidgets.length; x++) + for (var x = 0; x < this.columns.length; x++) { + if (!this.columns[x].visible) + { + continue; + } if (typeof _row[x] != "undefined" && _row[x].widget) { columnWidgets[x] = _row[x].widget; diff --git a/api/js/etemplate/et2_extension_nextmatch_rowProvider.js b/api/js/etemplate/et2_extension_nextmatch_rowProvider.js index b09c354966..89d7e6b584 100644 --- a/api/js/etemplate/et2_extension_nextmatch_rowProvider.js +++ b/api/js/etemplate/et2_extension_nextmatch_rowProvider.js @@ -236,7 +236,7 @@ var et2_nextmatch_rowProvider = (function(){ "use strict"; return ClassWithAttri _getVariableAttributeSet: function(_widget) { var variableAttributes = []; - _widget.iterateOver(function(_widget) { + var process = function(_widget) { // Create the attribtues var hasAttr = false; var widgetData = { @@ -270,7 +270,19 @@ var et2_nextmatch_rowProvider = (function(){ "use strict"; return ClassWithAttri variableAttributes.push(widgetData); } - }, this); + }; + + // Check each column + var columns = _widget.getChildren(); + for(var i = 0; i < columns.length; i++) + { + // If column is hidden, don't process it + if(this._context && this._context.columns && this._context.columns[i] && !this._context.columns[i].visible) + { + continue; + } + columns[i].iterateOver(process, this); + } return variableAttributes; }, @@ -570,7 +582,8 @@ var et2_nextmatch_rowWidget = (function(){ "use strict"; return et2_widget.exten */ createWidgets: function(_widgets) { // Clone the given the widgets with this element as parent - this._widgets = new Array(_widgets.length); + this._widgets = new Array(); + var row_id = 0; for (var i = 0; i < _widgets.length; i++) { // Disabled columns might be missing widget - skip it @@ -581,8 +594,9 @@ var et2_nextmatch_rowWidget = (function(){ "use strict"; return et2_widget.exten // Set column alignment from widget if(this._widgets[i].align) { - this._row.childNodes[i].align = this._widgets[i].align; + this._row.childNodes[row_id].align = this._widgets[i].align; } + row_id++; } }, @@ -593,12 +607,16 @@ var et2_nextmatch_rowWidget = (function(){ "use strict"; return et2_widget.exten * @return {DOMElement} */ getDOMNode: function(_sender) { + var row_id = 0; for (var i = 0; i < this._widgets.length; i++) { + // Disabled columns might be missing widget - skip it + if(!this._widgets[i]) continue; if (this._widgets[i] == _sender) { - return this._row.childNodes[i].childNodes[0]; // Return the i-th td tag + return this._row.childNodes[row_id].childNodes[0]; // Return the i-th td tag } + row_id++; } return null;