Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.$nextTick(() => {
const allWidth = !this.columns.some(cell => !cell.width); // each column set a width
if (allWidth) {
this.tableWidth = this.columns.map(cell => cell.width).reduce((a, b) => a + b);
} else {
this.tableWidth = parseInt(getStyle(this.$el, 'width')) - 1;
}
this.columnsWidth = {};
this.$nextTick(() => {
let columnsWidth = {};
let fixedLeftwidth = 0;
let fixedRightwidth = this.bodyRealHeight>this.bodyHeight?this.scrollBarWidth:0;
const $td = this.data.length>0?this.$refs.tbody.$el.querySelectorAll('tbody tr')[0].querySelectorAll('td'):this.$refs.header.querySelectorAll('thead tr')[0].querySelectorAll('th');
for (let i = 0; i < $td.length; i++) { // can not use forEach in Firefox
const column = this.cloneColumns[i];
let width = parseInt(getStyle($td[i], 'width'));
if (column.fixed && column.fixed === 'left') {
fixedLeftwidth += width;
}
if (column.fixed && column.fixed === 'right') {
fixedRightwidth += width;
}
if (column.width) {
width = column.width;
}
this.cloneColumns[i]._width = width;
// this.cloneColumns[i].width = width;
columnsWidth[column._index] = {
width: width
};
}
this.columnsWidth = columnsWidth;
//change fixed style
if (fixedLeftwidth>0) this.fixedTableStyle.width = `${fixedLeftwidth}px`;
if (fixedRightwidth>0) this.fixedRightTableStyle.width = `${fixedRightwidth}px`;
});
// get table real height,for fixed when set height prop,but height < table's height,show scrollBarWidth
this.bodyRealHeight = parseInt(getStyle(this.$refs.tbody.$el, 'height'));
});
},
this.$nextTick(() => {
let columnsWidth = {};
let fixedLeftwidth = 0;
let fixedRightwidth = this.bodyRealHeight>this.bodyHeight?this.scrollBarWidth:0;
const $td = this.data.length>0?this.$refs.tbody.$el.querySelectorAll('tbody tr')[0].querySelectorAll('td'):this.$refs.header.querySelectorAll('thead tr')[0].querySelectorAll('th');
for (let i = 0; i < $td.length; i++) { // can not use forEach in Firefox
const column = this.cloneColumns[i];
let width = parseInt(getStyle($td[i], 'width'));
if (column.fixed && column.fixed === 'left') {
fixedLeftwidth += width;
}
if (column.fixed && column.fixed === 'right') {
fixedRightwidth += width;
}
if (column.width) {
width = column.width;
}
this.cloneColumns[i]._width = width;
// this.cloneColumns[i].width = width;
columnsWidth[column._index] = {
width: width
};
}
this.columnsWidth = columnsWidth;
this.$nextTick(() => {
const titleHeight = parseInt(getStyle(this.$refs.title, 'height')) || 0;
const headerHeight = parseInt(getStyle(this.$refs.header, 'height')) || 0;
const footerHeight = parseInt(getStyle(this.$refs.footer, 'height')) || 0;
this.bodyHeight = this.height - titleHeight - headerHeight - footerHeight;
});
} else {
this.$nextTick(() => {
const titleHeight = parseInt(getStyle(this.$refs.title, 'height')) || 0;
const headerHeight = parseInt(getStyle(this.$refs.header, 'height')) || 0;
const footerHeight = parseInt(getStyle(this.$refs.footer, 'height')) || 0;
this.bodyHeight = this.height - titleHeight - headerHeight - footerHeight;
});
} else {
this.$nextTick(() => {
const titleHeight = parseInt(getStyle(this.$refs.title, 'height')) || 0;
const headerHeight = parseInt(getStyle(this.$refs.header, 'height')) || 0;
const footerHeight = parseInt(getStyle(this.$refs.footer, 'height')) || 0;
this.bodyHeight = this.height - titleHeight - headerHeight - footerHeight;
});
} else {