mirror of https://github.com/ElemeFE/element
Table: fix header table not display (#17341)
parent
fcaec91eb9
commit
fa7bdd42be
|
@ -33,10 +33,10 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onColumnsChange() {
|
onColumnsChange(layout) {
|
||||||
const cols = this.$el.querySelectorAll('colgroup > col');
|
const cols = this.$el.querySelectorAll('colgroup > col');
|
||||||
if (!cols.length) return;
|
if (!cols.length) return;
|
||||||
const flattenColumns = this.tableLayout.getFlattenColumns();
|
const flattenColumns = layout.getFlattenColumns();
|
||||||
const columnsMap = {};
|
const columnsMap = {};
|
||||||
flattenColumns.forEach((column) => {
|
flattenColumns.forEach((column) => {
|
||||||
columnsMap[column.id] = column;
|
columnsMap[column.id] = column;
|
||||||
|
|
|
@ -97,7 +97,7 @@ class TableLayout {
|
||||||
if (this.showHeader && !headerWrapper) return;
|
if (this.showHeader && !headerWrapper) return;
|
||||||
|
|
||||||
// fix issue (https://github.com/ElemeFE/element/pull/16956)
|
// fix issue (https://github.com/ElemeFE/element/pull/16956)
|
||||||
const headerTrElm = headerWrapper.querySelector('.el-table__header tr');
|
const headerTrElm = headerWrapper ? headerWrapper.querySelector('.el-table__header tr') : null;
|
||||||
const noneHeader = this.headerDisplayNone(headerTrElm);
|
const noneHeader = this.headerDisplayNone(headerTrElm);
|
||||||
|
|
||||||
const headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
|
const headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
|
||||||
|
@ -119,6 +119,7 @@ class TableLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
headerDisplayNone(elm) {
|
headerDisplayNone(elm) {
|
||||||
|
if (!elm) return true;
|
||||||
let headerChild = elm;
|
let headerChild = elm;
|
||||||
while (headerChild.tagName !== 'DIV') {
|
while (headerChild.tagName !== 'DIV') {
|
||||||
if (getComputedStyle(headerChild).display === 'none') {
|
if (getComputedStyle(headerChild).display === 'none') {
|
||||||
|
|
|
@ -383,6 +383,7 @@
|
||||||
updateScrollY() {
|
updateScrollY() {
|
||||||
const changed = this.layout.updateScrollY();
|
const changed = this.layout.updateScrollY();
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
this.layout.notifyObservers('scrollable');
|
||||||
this.layout.updateColumnsWidth();
|
this.layout.updateColumnsWidth();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue