|
12 | 12 | 'show-shadow': showShadow, |
13 | 13 | }" |
14 | 14 | > |
15 | | - <table> |
| 15 | + <table :class="{'fixed': fixedHeaders.length}"> |
16 | 16 | <colgroup> |
17 | 17 | <col |
18 | 18 | v-for="(header, index) in headersForRender" |
|
25 | 25 | <th |
26 | 26 | v-for="(header, index) in headersForRender" |
27 | 27 | :key="index" |
28 | | - colspan="1" |
29 | | - rowspan="1" |
30 | 28 | :class="{ |
31 | 29 | sortable: header.sortable, |
32 | 30 | 'none': header.sortable && header.sortType === 'none', |
|
78 | 76 | <td |
79 | 77 | v-for="(column, i) in headerColumns" |
80 | 78 | :key="i" |
81 | | - colspan="1" |
82 | | - rowspan="1" |
83 | 79 | :style="getFixedDistance(column, 'td')" |
84 | 80 | :class="{'hasShadow': column === lastFixedColumn}" |
85 | 81 | > |
@@ -497,12 +493,6 @@ type FixedColumnsInfo = { |
497 | 493 | width: number, |
498 | 494 | }; |
499 | 495 |
|
500 | | -const getColStyle = (header: HeaderForRender): string | undefined => { |
501 | | - const width = header.width ?? (header.fixed ? 100 : null); |
502 | | - if (width) return `width: ${width}px; min-width: ${width}px;`; |
503 | | - return undefined; |
504 | | -}; |
505 | | -
|
506 | 496 | const hasFixedColumnsFromUser = computed(() => props.headers.findIndex((header) => header.fixed) !== -1); |
507 | 497 | const fixedHeadersFromUser = computed(() => { |
508 | 498 | if (hasFixedColumnsFromUser.value) return props.headers.filter((header) => header.fixed); |
@@ -557,6 +547,12 @@ const lastFixedColumn = computed((): string => { |
557 | 547 | return fixedHeaders.value[fixedHeaders.value.length - 1].value; |
558 | 548 | }); |
559 | 549 |
|
| 550 | +const getColStyle = (header: HeaderForRender): string | undefined => { |
| 551 | + const width = header.width ?? (fixedHeaders.value.length ? 100 : null); |
| 552 | + if (width) return `width: ${width}px; min-width: ${width}px;`; |
| 553 | + return undefined; |
| 554 | +}; |
| 555 | +
|
560 | 556 | const fixedColumnsInfos = computed((): FixedColumnsInfo[] => { |
561 | 557 | if (!fixedHeaders.value.length) return []; |
562 | 558 | const fixedHeadersWidthArr = fixedHeaders.value.map((header) => header.width ?? 100); |
@@ -1001,6 +997,9 @@ defineExpose({ |
1001 | 997 | } |
1002 | 998 |
|
1003 | 999 | table { |
| 1000 | + &.fixed { |
| 1001 | + table-layout: fixed; |
| 1002 | + } |
1004 | 1003 | display: table; |
1005 | 1004 | margin: 0px; |
1006 | 1005 | width: 100%; |
|
0 commit comments