diff --git a/api/js/etemplate/et2_dataview.js b/api/js/etemplate/et2_dataview.js index 17e0df8fc5..50d1be8299 100644 --- a/api/js/etemplate/et2_dataview.js +++ b/api/js/etemplate/et2_dataview.js @@ -380,10 +380,12 @@ var et2_dataview = /** @class */ (function () { */ et2_dataview.prototype._buildGrid = function () { // Create the collection of column ids - var colIds = new Array(this.columns.length); + var colIds = []; 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 if (this.rowProvider) { this.rowProvider.destroy(); diff --git a/api/js/etemplate/et2_dataview.ts b/api/js/etemplate/et2_dataview.ts index aa22248be2..5685e697b7 100644 --- a/api/js/etemplate/et2_dataview.ts +++ b/api/js/etemplate/et2_dataview.ts @@ -534,14 +534,17 @@ export class et2_dataview private _buildGrid() { // Create the collection of column ids - var colIds = new Array(this.columns.length); + var colIds = []; 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 - if (this.rowProvider) + if(this.rowProvider) { this.rowProvider.destroy(); } diff --git a/api/js/etemplate/et2_dataview_view_rowProvider.js b/api/js/etemplate/et2_dataview_view_rowProvider.js index b793cba537..166f60fb70 100644 --- a/api/js/etemplate/et2_dataview_view_rowProvider.js +++ b/api/js/etemplate/et2_dataview_view_rowProvider.js @@ -85,19 +85,22 @@ var et2_dataview_rowProvider = /** @class */ (function () { this._prototypes["fullRow"] = tr; }; et2_dataview_rowProvider.prototype._createDefaultPrototype = function () { - var tr = jQuery(document.createElement("tr")); - // Append a td for each column - for (var i = 0; i < this._columnIds.length; i++) { - var td = jQuery(document.createElement("td")) - .addClass(this._outerId + "_td_" + this._columnIds[i]) - .appendTo(tr); - var div = jQuery(document.createElement("div")) - .addClass(this._outerId + "_div_" + this._columnIds[i]) - .addClass("innerContainer") - .appendTo(td); - } - this._prototypes["default"] = tr; - }; + var tr = jQuery(document.createElement("tr")); + // Append a td for each column + for (var _i = 0, _a = this._columnIds; _i < _a.length; _i++) { + var column = _a[_i]; + if (!column) + continue; + var td = jQuery(document.createElement("td")) + .addClass(this._outerId + "_td_" + column) + .appendTo(tr); + var div = jQuery(document.createElement("div")) + .addClass(this._outerId + "_div_" + column) + .addClass("innerContainer") + .appendTo(td); + } + this._prototypes["default"] = tr; + }; et2_dataview_rowProvider.prototype._createEmptyPrototype = function () { this._prototypes["empty"] = jQuery(document.createElement("tr")); }; diff --git a/api/js/etemplate/et2_dataview_view_rowProvider.ts b/api/js/etemplate/et2_dataview_view_rowProvider.ts index d5d182a79d..6c3eeb1862 100644 --- a/api/js/etemplate/et2_dataview_view_rowProvider.ts +++ b/api/js/etemplate/et2_dataview_view_rowProvider.ts @@ -117,13 +117,15 @@ export class et2_dataview_rowProvider 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 8643780ee4..468580914d 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -949,21 +949,23 @@ var et2_nextmatch = /** @class */ (function (_super) { } }; et2_nextmatch.prototype._parseDataRow = function (_row, _rowData, _colData) { - var columnWidgets = new Array(this.columns.length); - _row.sort(function (a, b) { - return a.colData.order - b.colData.order; - }); - for (var x = 0; x < columnWidgets.length; x++) { - if (typeof _row[x] != "undefined" && _row[x].widget) { - columnWidgets[x] = _row[x].widget; - // Append the widget to this container - this.addChild(_row[x].widget); - } - else { - columnWidgets[x] = _row[x].widget; - } - // Pass along column alignment - if (_row[x].align && columnWidgets[x]) { + var columnWidgets = []; + _row.sort(function (a, b) { + return a.colData.order - b.colData.order; + }); + 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; + // Append the widget to this container + this.addChild(_row[x].widget); + } else { + columnWidgets[x] = _row[x].widget; + } + // Pass along column alignment + if (_row[x].align && columnWidgets[x]) { columnWidgets[x].align = _row[x].align; } } diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index 72ad16f01e..15752ab109 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -196,10 +196,10 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 // Popup to select columns private selectPopup: any; - public static legacyOptions = ["template","hide_header","header_left","header_right"]; + public static legacyOptions = ["template", "hide_header", "header_left", "header_right"]; private template: any; - columns: {widget: et2_widget}[]; + columns: { visible: boolean, widget: et2_widget }[]; private sortedColumnsList: string[]; // If we need the nextmatch to have a value, keep it here. @@ -1322,15 +1322,20 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 _parseDataRow( _row, _rowData, _colData) { - const columnWidgets = new Array(this.columns.length); + const columnWidgets = []; - _row.sort(function(a,b) { - return a.colData.order - b.colData.order; - }); + _row.sort(function (a, b) + { + return a.colData.order - b.colData.order; + }); - for (let x = 0; x < columnWidgets.length; x++) + for (let x = 0; x < this.columns.length; x++) { - if (typeof _row[x] != "undefined" && _row[x].widget) + 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 a333c9d148..fbb764e348 100644 --- a/api/js/etemplate/et2_extension_nextmatch_rowProvider.js +++ b/api/js/etemplate/et2_extension_nextmatch_rowProvider.js @@ -219,35 +219,44 @@ var et2_nextmatch_rowProvider = /** @class */ (function () { */ et2_nextmatch_rowProvider.prototype._getVariableAttributeSet = function (_widget) { var variableAttributes = []; - _widget.iterateOver(function (_widget) { - // Create the attribtues - var hasAttr = false; - var widgetData = { - "widget": _widget, - "data": [] - }; - // Get all attribute values - for (var key in _widget.attributes) { - if (!_widget.attributes[key].ignore && - typeof _widget.options[key] != "undefined") { + var process = function (_widget) { + // Create the attribtues + var hasAttr = false; + var widgetData = { + "widget": _widget, + "data": [] + }; + // Get all attribute values + for (var key in _widget.attributes) { + if (!_widget.attributes[key].ignore && + typeof _widget.options[key] != "undefined") { var val = _widget.options[key]; // TODO: Improve detection if (typeof val == "string" && val.indexOf("$") >= 0) { hasAttr = true; widgetData.data.push({ - "attribute": key, - "expression": val - }); - } - } - } - // Add the entry if there is any data in it - if (hasAttr) { - variableAttributes.push(widgetData); - } - }, this); - return variableAttributes; - }; + "attribute": key, + "expression": val + }); + } + } + } + // Add the entry if there is any data in it + if (hasAttr) { + variableAttributes.push(widgetData); + } + }; + // 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; + }; et2_nextmatch_rowProvider.prototype._seperateWidgets = function (_varAttrs) { // The detachable array contains all widgets which implement the // et2_IDetachedDOM interface for all needed attributes @@ -467,18 +476,20 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) { * @param {array} _widgets */ et2_nextmatch_rowWidget.prototype.createWidgets = function (_widgets) { - // Clone the given the widgets with this element as parent - this._widgets = new Array(_widgets.length); - for (var i = 0; i < _widgets.length; i++) { - // Disabled columns might be missing widget - skip it - if (!_widgets[i]) - continue; - this._widgets[i] = _widgets[i].clone(this); - this._widgets[i].loadingFinished(); - // Set column alignment from widget - if (this._widgets[i].align) { - this._row.childNodes[i].align = this._widgets[i].align; - } + // Clone the given the widgets with this element as parent + this._widgets = []; + var row_id = 0; + for (var i = 0; i < _widgets.length; i++) { + // Disabled columns might be missing widget - skip it + if (!_widgets[i]) + continue; + this._widgets[i] = _widgets[i].clone(this); + this._widgets[i].loadingFinished(); + // Set column alignment from widget + if (this._widgets[i].align) { + this._row.childNodes[row_id].align = this._widgets[i].align; + } + row_id++; } }; /** @@ -488,11 +499,16 @@ var et2_nextmatch_rowWidget = /** @class */ (function (_super) { * @return {DOMElement} */ et2_nextmatch_rowWidget.prototype.getDOMNode = function (_sender) { + var row_id = 0; for (var i = 0; i < this._widgets.length; i++) { - if (this._widgets[i] == _sender) { - return this._row.childNodes[i].childNodes[0]; // Return the i-th td tag - } - } + // Disabled columns might be missing widget - skip it + if (!this._widgets[i]) + continue; + if (this._widgets[i] == _sender) { + return this._row.childNodes[row_id].childNodes[0]; // Return the i-th td tag + } + row_id++; + } return null; }; return et2_nextmatch_rowWidget; diff --git a/api/js/etemplate/et2_extension_nextmatch_rowProvider.ts b/api/js/etemplate/et2_extension_nextmatch_rowProvider.ts index 0401d7a4f9..787c271a80 100644 --- a/api/js/etemplate/et2_extension_nextmatch_rowProvider.ts +++ b/api/js/etemplate/et2_extension_nextmatch_rowProvider.ts @@ -258,9 +258,10 @@ export class et2_nextmatch_rowProvider */ _getVariableAttributeSet( _widget) { - var variableAttributes = []; + let variableAttributes = []; - _widget.iterateOver(function(_widget) { + const process = function (_widget) + { // Create the attribtues var hasAttr = false; var widgetData = { @@ -269,32 +270,43 @@ export class et2_nextmatch_rowProvider }; // Get all attribute values - for (var key in _widget.attributes) + for (const key in _widget.attributes) { - if (!_widget.attributes[key].ignore && - typeof _widget.options[key] != "undefined") + if(!_widget.attributes[key].ignore && + typeof _widget.options[key] != "undefined") { - var val = _widget.options[key]; + const val = _widget.options[key]; // TODO: Improve detection - if (typeof val == "string" && val.indexOf("$") >= 0) + if(typeof val == "string" && val.indexOf("$") >= 0) { hasAttr = true; widgetData.data.push({ - "attribute": key, - "expression": val - }); + "attribute": key, + "expression": val + }); } } } // Add the entry if there is any data in it - if (hasAttr) + if(hasAttr) { variableAttributes.push(widgetData); } + }; - }, this); + // Check each column + const 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; } @@ -603,7 +615,8 @@ class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode createWidgets( _widgets) { // Clone the given the widgets with this element as parent - this._widgets = new Array(_widgets.length); + this._widgets = []; + let row_id = 0; for (var i = 0; i < _widgets.length; i++) { // Disabled columns might be missing widget - skip it @@ -614,8 +627,9 @@ class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode // 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++; } } @@ -627,12 +641,16 @@ class et2_nextmatch_rowWidget extends et2_widget implements et2_IDOMNode */ getDOMNode( _sender) { + var row_id = 0; for (var i = 0; i < this._widgets.length; i++) { - if (this._widgets[i] == _sender) + // 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;