diff --git a/package.json b/package.json index 47a2e41b..26656d40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tablefilter", - "version": "0.5.27", + "version": "0.5.28", "description": "A Javascript library making HTML tables filterable and a bit more", "license": "MIT", "author": { diff --git a/src/modules/gridLayout.js b/src/modules/gridLayout.js index 3d795604..789d12e1 100644 --- a/src/modules/gridLayout.js +++ b/src/modules/gridLayout.js @@ -301,7 +301,7 @@ export class GridLayout extends Feature { */ setDefaultColWidths() { let tf = this.tf; - if (tf.hasColWidths) { + if (tf.colWidths.length > 0) { return; } for (let k = 0, len = tf.getCellsNb(); k < len; k++) { @@ -316,7 +316,6 @@ export class GridLayout extends Feature { } tf.colWidths[k] = colW; } - tf.hasColWidths = true; tf.setColWidths(); } diff --git a/src/tablefilter.js b/src/tablefilter.js index 0835b754..1fd39305 100644 --- a/src/tablefilter.js +++ b/src/tablefilter.js @@ -153,7 +153,11 @@ export class TableFilter { //Start row this.refRow = isUndef(startRow) ? 2 : (startRow + 1); - // get the collection of filter type by column + /** + * Collection of filter type by column + * @type {Array} + * @private + */ this.filterTypes = [].map.call( (this.dom().rows[this.refRow] || this.dom().rows[0]).cells, (cell, idx) => { @@ -307,18 +311,11 @@ export class TableFilter { */ this.alternateRows = Boolean(f.alternate_rows); - /** - * Indicate whether columns widths are set - * @type {Boolean} - * @private - */ - this.hasColWidths = isArray(f.col_widths); - /** * Columns widths array * @type {Array} */ - this.colWidths = this.hasColWidths ? f.col_widths : []; + this.colWidths = f.col_widths || []; /** * Css class for a filter element @@ -938,14 +935,7 @@ export class TableFilter { * @type {Array} * @private */ - this.extensions = f.extensions; - - /** - * Determine whether extensions are loaded - * @type {Boolean} - * @private - */ - this.hasExtensions = isArray(this.extensions); + this.extensions = f.extensions || []; /*** themes ***/ /** @@ -1107,9 +1097,7 @@ export class TableFilter { paging ]); - if (this.hasColWidths && !this.gridLayout) { - this.setColWidths(); - } + this.setColWidths(); //TF css class is added to table if (!this.gridLayout) { @@ -1381,11 +1369,11 @@ export class TableFilter { * Initialise all the extensions defined in the configuration object */ initExtensions() { - if (!this.hasExtensions) { + let exts = this.extensions; + if (exts.length === 0) { return; } - let exts = this.extensions; // Set config's publicPath dynamically for Webpack... __webpack_public_path__ = this.basePath; @@ -1531,9 +1519,7 @@ export class TableFilter { this.removeToolbar(); - if (this.hasExtensions) { - this.destroyExtensions(); - } + this.destroyExtensions(); this.validateAllRows(); @@ -2674,13 +2660,14 @@ export class TableFilter { * @param {Element} tbl DOM element */ setColWidths(tbl) { - if (!this.hasColWidths) { + let colWidths = this.colWidths; + if (colWidths.length === 0 || this.gridLayout) { return; } + tbl = tbl || this.dom(); let nbCols = this.nbCells; - let colWidths = this.colWidths; let colTags = tag(tbl, 'col'); let tblHasColTag = colTags.length > 0; let frag = !tblHasColTag ? doc.createDocumentFragment() : null;