|
@@ -8,6 +8,7 @@ class TableLayout {
|
|
|
this.store = null;
|
|
|
this.columns = null;
|
|
|
this.fit = true;
|
|
|
+ this.showHeader = true;
|
|
|
|
|
|
this.height = null;
|
|
|
this.scrollX = false;
|
|
@@ -50,16 +51,21 @@ class TableLayout {
|
|
|
}
|
|
|
|
|
|
setHeight(height) {
|
|
|
- if (typeof height === 'string' && /^\d+$/.test(height)) {
|
|
|
- height = Number(height);
|
|
|
+ const el = this.table.$el;
|
|
|
+ if (typeof height === 'string') {
|
|
|
+ if (/^\d+$/.test(height)) {
|
|
|
+ height = Number(height);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
this.height = height;
|
|
|
|
|
|
- const el = this.table.$el;
|
|
|
- if (!isNaN(height) && el) {
|
|
|
+ if (!el) return;
|
|
|
+ if (!isNaN(height)) {
|
|
|
el.style.height = height + 'px';
|
|
|
|
|
|
+ this.updateHeight();
|
|
|
+ } else if (typeof height === 'string') {
|
|
|
this.updateHeight();
|
|
|
}
|
|
|
}
|
|
@@ -67,12 +73,23 @@ class TableLayout {
|
|
|
updateHeight() {
|
|
|
const height = this.tableHeight = this.table.$el.clientHeight;
|
|
|
const { headerWrapper } = this.table.$refs;
|
|
|
- if (!headerWrapper) return;
|
|
|
- const headerHeight = this.headerHeight = headerWrapper.offsetHeight;
|
|
|
- const bodyHeight = height - headerHeight;
|
|
|
- if (this.height !== null && !isNaN(this.height)) this.bodyHeight = bodyHeight;
|
|
|
- this.fixedBodyHeight = this.scrollX ? bodyHeight - this.gutterWidth : bodyHeight;
|
|
|
- this.viewportHeight = this.scrollX ? height - this.gutterWidth : height;
|
|
|
+ if (this.showHeader && !headerWrapper) return;
|
|
|
+ if (!this.showHeader) {
|
|
|
+ this.headerHeight = 0;
|
|
|
+ if (this.height !== null && (!isNaN(this.height) || typeof this.height === 'string')) {
|
|
|
+ this.bodyHeight = height;
|
|
|
+ }
|
|
|
+ this.fixedBodyHeight = this.scrollX ? height - this.gutterWidth : height;
|
|
|
+ this.viewportHeight = this.scrollX ? height - this.gutterWidth : height;
|
|
|
+ } else {
|
|
|
+ const headerHeight = this.headerHeight = headerWrapper.offsetHeight;
|
|
|
+ const bodyHeight = height - headerHeight;
|
|
|
+ if (this.height !== null && (!isNaN(this.height) || typeof this.height === 'string')) {
|
|
|
+ this.bodyHeight = bodyHeight;
|
|
|
+ }
|
|
|
+ this.fixedBodyHeight = this.scrollX ? bodyHeight - this.gutterWidth : bodyHeight;
|
|
|
+ this.viewportHeight = this.scrollX ? height - this.gutterWidth : height;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
update() {
|