Fixed #1018 - Resize support for Scrollable Tables

pull/1281/head
Cagatay Civici 2021-05-17 15:53:35 +03:00
parent d7c01c8f6e
commit 86a91ae4c3
1 changed files with 30 additions and 4 deletions

View File

@ -1050,15 +1050,24 @@ export default {
let nextColumnWidth = nextColumn.offsetWidth - delta;
if (newColumnWidth > 15 && nextColumnWidth > 15) {
this.resizeColumnElement.style.width = newColumnWidth + 'px';
if(nextColumn) {
nextColumn.style.width = nextColumnWidth + 'px';
if (!this.scrollable) {
this.resizeColumnElement.style.width = newColumnWidth + 'px';
if(nextColumn) {
nextColumn.style.width = nextColumnWidth + 'px';
}
}
else {
this.resizeTableCells(newColumnWidth, nextColumnWidth);
}
}
}
else if (this.columnResizeMode === 'expand') {
this.$refs.table.style.width = this.$refs.table.offsetWidth + delta + 'px';
this.resizeColumnElement.style.width = newColumnWidth + 'px';
if (!this.scrollable)
this.resizeColumnElement.style.width = newColumnWidth + 'px';
else
this.resizeTableCells(newColumnWidth);
}
this.$emit('column-resize-end', {
@ -1077,6 +1086,23 @@ export default {
this.saveState();
}
},
resizeTableCells(newColumnWidth, nextColumnWidth) {
let colIndex = DomHandler.index(this.resizeColumnElement);
let children = this.$refs.table.children;
for (let child of children) {
for (let row of child.children) {
let resizeCell = row.children[colIndex];
resizeCell.style.flex = '0 0 ' + newColumnWidth + 'px';
if (this.columnResizeMode === 'fit') {
let nextCell = resizeCell.nextElementSibling;
if (nextCell) {
nextCell.style.flex = '0 0 ' + nextColumnWidth + 'px';
}
}
}
}
},
resizeColGroup(table, resizeColumnIndex, newColumnWidth, nextColumnWidth) {
if(table) {
let colGroup = table.children[0].nodeName === 'COLGROUP' ? table.children[0] : null;