From f45eabd94398e620bd9462ed84d9d84f4652a7e1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 2 Apr 2026 15:19:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=97=E5=AE=BD?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.js | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.js b/src/BootstrapBlazor/Components/Table/Table.razor.js index 8b0922b13c9..290536a7cb1 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.js +++ b/src/BootstrapBlazor/Components/Table/Table.razor.js @@ -539,14 +539,7 @@ const resetTableWidth = table => { table.tables.forEach(t => { const group = [...t.children].find(i => i.nodeName === 'COLGROUP') if (group) { - let width = 0; - [...group.children].forEach(col => { - let colWidth = parseInt(col.style.width); - if (isNaN(colWidth)) { - colWidth = 100; - } - width += colWidth; - }) + const width = getTableWidthByColumnGroup(t, 100); t.style.width = `${width}px`; saveColumnWidth(table); @@ -1047,15 +1040,33 @@ const saveColumnWidth = table => { })); } +const getTableWidthByColumnGroup = (table, defaultWidth) => { + return [...table.querySelectorAll('colgroup col')] + .map((col, index) => getColumnRenderWidth(table, col, index, defaultWidth)) + .reduce((accumulator, val) => accumulator + val, 0); +} + +const getColumnRenderWidth = (table, col, index, defaultWidth) => { + let width = parseFloat(col.style.width); + if (!isNaN(width) && width > 0) { + return width; + } + + const header = table.querySelectorAll('thead > tr:last-child > th').item(index); + width = header?.offsetWidth ?? 0; + if (width > 0) { + return width; + } + + const row = [...table.querySelectorAll('tbody > tr')].find(i => !i.classList.contains('is-detail')); + width = row?.children.item(index)?.offsetWidth ?? 0; + return width > 0 ? width : defaultWidth; +} + const setTableDefaultWidth = table => { if (table.tables.length > 0 && isVisible(table.tables[0])) { const { scrollWidth, columnMinWidth } = table.options; - const tableWidth = [...table.tables[0].querySelectorAll('col')] - .map(i => { - const colWidth = parseFloat(i.style.width); - return isNaN(colWidth) ? columnMinWidth : colWidth; - }) - .reduce((accumulator, val) => accumulator + val, 0); + const tableWidth = getTableWidthByColumnGroup(table.tables[0], columnMinWidth); if (tableWidth > table.el.offsetWidth) { table.tables[0].style.setProperty('width', `${tableWidth}px`); From 6a3fc53592dd683cfcc9059467147c0c0f8c92ef Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 2 Apr 2026 15:29:33 +0800 Subject: [PATCH 2/5] chore: bump version 10.5.1-beta02 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 6ce5e82c256..4acbd54ad8d 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 10.5.0 + 10.5.1-beta02 From 99a6d078bcedec54e0f4bd09347372c9caf9bd4a Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 3 Apr 2026 22:09:54 +0800 Subject: [PATCH 3/5] =?UTF-8?q?doc:=20=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Table/Table.razor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor b/src/BootstrapBlazor/Components/Table/Table.razor index e5b4eb50373..7e058ada398 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor +++ b/src/BootstrapBlazor/Components/Table/Table.razor @@ -1146,9 +1146,9 @@ RenderFragment RenderColumnListItem => item => @; From 69cd81b29c1728afd6e3d227d4640e6037568654 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 3 Apr 2026 22:10:19 +0800 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=E5=88=97=E5=92=8C=E5=A4=A7?= =?UTF-8?q?=E4=BA=8E=E8=A1=A8=E6=A0=BC=E5=AE=BD=E5=BA=A6=E6=97=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Table/Table.razor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.js b/src/BootstrapBlazor/Components/Table/Table.razor.js index 290536a7cb1..844d4950fc8 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.js +++ b/src/BootstrapBlazor/Components/Table/Table.razor.js @@ -540,7 +540,9 @@ const resetTableWidth = table => { const group = [...t.children].find(i => i.nodeName === 'COLGROUP') if (group) { const width = getTableWidthByColumnGroup(t, 100); - t.style.width = `${width}px`; + if (width >= t.offsetWidth) { + t.style.width = `${width}px`; + } saveColumnWidth(table); } From b759996f5b96bfabea8512cd537a227313666de2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 3 Apr 2026 22:51:39 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.js b/src/BootstrapBlazor/Components/Table/Table.razor.js index 844d4950fc8..5ef90a21d8a 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.js +++ b/src/BootstrapBlazor/Components/Table/Table.razor.js @@ -536,19 +536,41 @@ const setExcelKeyboardListener = table => { } const resetTableWidth = table => { + const { options: { scrollWidth } } = table; table.tables.forEach(t => { const group = [...t.children].find(i => i.nodeName === 'COLGROUP') if (group) { + const colgroup = getLastColgroup(t, group); + if (colgroup) { + colgroup.style = null; + } const width = getTableWidthByColumnGroup(t, 100); - if (width >= t.offsetWidth) { + if (width >= t.parentElement.offsetWidth + scrollWidth) { t.style.width = `${width}px`; } + else { + t.style.width = null; + } saveColumnWidth(table); } }) } +const getLastColgroup = (table, group) => { + const p = table.parentElement; + if (p) { + const length = group.children.length; + if (p.classList.contains("table-fixed-header")) { + return group.children[length - 2]; + } + else { + return group.children[length - 1]; + } + } + return null; +} + const setResizeListener = table => { if (table.options.showColumnWidthTooltip) { table.handlers.setResizeHandler = e => {