Skip to content

Commit b56bd12

Browse files
authored
Merge pull request #3806 from VisActor/3796-bug-adaptive-with-setting-maxwidth
3796 bug adaptive with setting maxwidth
2 parents 0c874ac + 63d977f commit b56bd12

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "fix: supplement adaptive widthAdaptiveMode logic #3796\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vtable"
7+
}
8+
],
9+
"packageName": "@visactor/vtable",
10+
"email": "892739385@qq.com"
11+
}

packages/vtable/examples/cell-move/column-move.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ export function createTable() {
213213
}
214214
],
215215
dragOrder: {
216-
dragHeaderMode: 'column',
217-
validateDragOrderOnEnd(source, target) {
218-
console.log(source, target);
219-
return false;
220-
}
216+
dragHeaderMode: 'column'
217+
// validateDragOrderOnEnd(source, target) {
218+
// console.log(source, target);
219+
// return false;
220+
// }
221221
}
222222
// theme: VTable.themes.SIMPLIFY,
223223
// defaultRowHeight: 100,

packages/vtable/src/scenegraph/layout/compute-col-width.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ import { breakString } from '../utils/break-string';
2525
import { emptyCustomLayout } from '../../components/react/react-custom-layout';
2626
import { getOrApply } from '../../tools/helper';
2727

28+
/**
29+
* @description: 计算列宽
30+
* @param {BaseTableAPI} table
31+
* @param {number} colStart
32+
* @param {number} colEnd
33+
* @param {boolean} update 是否执行更新场景树
34+
*/
2835
export function computeColsWidth(table: BaseTableAPI, colStart?: number, colEnd?: number, update?: boolean): void {
2936
// const time = typeof window !== 'undefined' ? window.performance.now() : 0;
3037
(table as PivotTableAPI | ListTableAPI).internalProps.columnWidthConfig &&

packages/vtable/src/scenegraph/scenegraph.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,17 +1373,22 @@ export class Scenegraph {
13731373
table._clearColRangeWidthsMap();
13741374
const canvasWidth = table.tableNoFrameWidth;
13751375
let actualHeaderWidth = 0;
1376-
for (let col = 0; col < table.colCount; col++) {
1377-
if (
1378-
col < table.rowHeaderLevelCount ||
1379-
(table.isPivotChart() && col >= table.colCount - table.rightFrozenColCount)
1380-
) {
1381-
const colWidth = table.getColWidth(col);
1382-
actualHeaderWidth += colWidth;
1376+
let startCol = 0;
1377+
let endCol = table.colCount;
1378+
if (table.widthAdaptiveMode === 'only-body') {
1379+
for (let col = 0; col < table.colCount; col++) {
1380+
if (
1381+
col < table.rowHeaderLevelCount ||
1382+
(table.isPivotChart() && col >= table.colCount - table.rightFrozenColCount)
1383+
) {
1384+
const colWidth = table.getColWidth(col);
1385+
actualHeaderWidth += colWidth;
1386+
}
13831387
}
1388+
startCol = table.rowHeaderLevelCount;
1389+
endCol = table.isPivotChart() ? table.colCount - table.rightFrozenColCount : table.colCount;
13841390
}
1385-
const startCol = table.rowHeaderLevelCount;
1386-
const endCol = table.isPivotChart() ? table.colCount - table.rightFrozenColCount : table.colCount;
1391+
13871392
getAdaptiveWidth(canvasWidth - actualHeaderWidth, startCol, endCol, false, [], table, true);
13881393
} else if (table.autoFillWidth) {
13891394
table._clearColRangeWidthsMap();

0 commit comments

Comments
 (0)