Skip to content

Commit

Permalink
Fixed toggle column bug with complex header
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed May 6, 2022
1 parent e008a50 commit c670762
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class BootstrapTable {
searchables: []
}

Utils.updateFieldGroup(this.options.columns)
Utils.updateFieldGroup(this.options.columns, this.columns)

this.options.columns.forEach((columns, i) => {
const html = []
Expand Down
16 changes: 15 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default {
return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
},

updateFieldGroup (columns) {
updateFieldGroup (columns, fieldColumns) {
const allColumns = [].concat(...columns)

for (const c of columns) {
Expand All @@ -227,6 +227,20 @@ export default {
}
}
}

if (columns.length < 2) {
return
}

for (const column of fieldColumns) {
const sameColumns = allColumns.filter(col => col.fieldIndex === column.fieldIndex)

if (sameColumns.length > 1) {
for (const c of sameColumns) {
c.visible = column.visible
}
}
}
},

getScrollBarWidth () {
Expand Down

0 comments on commit c670762

Please sign in to comment.