diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index 87ea4a77c..9e28e5865 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -219,7 +219,9 @@ class BootstrapTable { this.columns = [] this.fieldsColumnsIndex = [] - Utils.setFieldIndex(this.options.columns) + if (this.optionsColumnsChanged !== false) { + Utils.setFieldIndex(this.options.columns) + } this.options.columns.forEach((columns, i) => { columns.forEach((_column, j) => { @@ -2434,6 +2436,7 @@ class BootstrapTable { if (Utils.compareObjects(this.options, options, true)) { return } + this.optionsColumnsChanged = !!options.columns this.options = Utils.extend(this.options, options) this.trigger('refresh-options', this.options) this.destroy() diff --git a/src/utils/index.js b/src/utils/index.js index 5a7752597..b2e467448 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -296,10 +296,6 @@ export default { const underColumns = allColumns.filter(col => col.fieldIndex === i) const column = underColumns[underColumns.length - 1] - if (!column) { - continue - } - if (underColumns.length > 1) { for (let j = 0; j < underColumns.length - 1; j++) { underColumns[j].visible = column.visible