diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index b7aad9d6f..0d7cc4c9a 100755 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -396,10 +396,6 @@ export default { } }, mounted() { - if (this.scrollable && (this.scrollDirection !== 'vertical' || this.rowGroupMode === 'subheader' || !this.resizableColumns)) { - this.updateScrollWidth(); - } - if (this.responsiveLayout === 'stack' && !this.scrollable) { this.createResponsiveStyle(); } @@ -416,10 +412,6 @@ export default { if (this.isStateful()) { this.saveState(); } - - if (this.scrollable && (this.scrollDirection !== 'vertical' || this.rowGroupMode === 'subheader')) { - this.updateScrollWidth(); - } }, methods: { columnProp(col, prop) { @@ -1088,7 +1080,9 @@ export default { } } else if (this.columnResizeMode === 'expand') { - this.$refs.table.style.width = this.$refs.table.offsetWidth + delta + 'px'; + const tableWidth = this.$refs.table.offsetWidth + delta + 'px'; + this.$refs.table.style.width = tableWidth; + this.$refs.table.style.minWidth = tableWidth; if (!this.scrollable) this.resizeColumnElement.style.width = newColumnWidth + 'px'; @@ -1538,7 +1532,7 @@ export default { state.columnWidths = widths.join(','); if (this.columnResizeMode === 'expand') { - state.tableWidth = DomHandler.getOuterWidth(this.$refs.table) + 'px'; + state.tableWidth = DomHandler.getOuterWidth(this.$refs.table) + 'px'; } }, restoreColumnWidths() { @@ -1547,6 +1541,7 @@ export default { if (this.columnResizeMode === 'expand' && this.tableWidthState) { this.$refs.table.style.width = this.tableWidthState; + this.$refs.table.style.minWidth = this.tableWidthState; this.$el.style.width = this.tableWidthState; } @@ -1636,16 +1631,6 @@ export default { this.columns.forEach(col => columnOrder.push(this.columnProp(col, 'columnKey')||this.columnProp(col, 'field'))); this.d_columnOrder = columnOrder; }, - updateScrollWidth() { - let parentElementHeight = DomHandler.width(this.$refs.table.parentElement); - - if (this.$refs.table.scrollWidth > parentElementHeight) { - this.$refs.table.style.width = this.$refs.table.scrollWidth + 'px'; - } - else { - this.$refs.table.style.width = parentElementHeight - DomHandler.calculateScrollbarWidth() + 'px'; - } - }, createResponsiveStyle() { if (!this.styleElement) { this.$el.setAttribute(this.attributeSelector, ''); @@ -1858,7 +1843,7 @@ export default { .p-datatable table { border-collapse: collapse; - width: 100%; + min-width: 100%; table-layout: fixed; } @@ -1898,10 +1883,6 @@ export default { overflow: auto; } -.p-datatable-scrollable .p-datatable-table { - display: block; -} - .p-datatable-scrollable .p-datatable-thead, .p-datatable-scrollable .p-datatable-tbody, .p-datatable-scrollable .p-datatable-tfoot {