Skip to content

Commit 4e7e125

Browse files
authored
fix(Table): toggle column not work after resize column width (#7726)
* refactor: 移除 return 关键字 * refactor: 格式化代码 * refactor: 增加列默认值 * chore: bump version 10.4.0-beta01 * fix: 修复逻辑错误
1 parent 6b0adec commit 4e7e125

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.3.3</Version>
4+
<Version>10.4.0-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function init(id, invoke, options) {
2323

2424
export function saveColumnList(tableName, columns) {
2525
const key = `bb-table-column-visiable-${tableName}`
26-
return localStorage.setItem(key, JSON.stringify(columns));
26+
localStorage.setItem(key, JSON.stringify(columns));
2727
}
2828

2929
export function reloadColumnList(tableName) {
@@ -432,7 +432,7 @@ const setExcelKeyboardListener = table => {
432432
}
433433

434434
const setFocus = target => {
435-
const handler = setTimeout(function () {
435+
const handler = setTimeout(function() {
436436
clearTimeout(handler);
437437
if (target.focus) {
438438
target.focus();
@@ -541,9 +541,15 @@ const resetTableWidth = table => {
541541
if (group) {
542542
let width = 0;
543543
[...group.children].forEach(col => {
544-
width += parseInt(col.style.width)
544+
let colWidth = parseInt(col.style.width);
545+
if (isNaN(colWidth)) {
546+
colWidth = 100;
547+
}
548+
width += colWidth;
545549
})
546-
t.style.width = `${width}px`
550+
t.style.width = `${width}px`;
551+
552+
saveColumnWidth(table);
547553
}
548554
})
549555
}

src/BootstrapBlazor/Dynamic/DataTableDynamicContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ private static bool GetShownColumns(ITableColumn col, IEnumerable<string>? invis
9696
ret = false;
9797
}
9898

99-
// 隐藏列优先 移除隐藏列
99+
// 隐藏列存在时隐藏列
100100
if (ret && hiddenColumns != null && hiddenColumns.Any(c => c.Equals(columnName, StringComparison.OrdinalIgnoreCase)))
101101
{
102102
col.Visible = false;
103103
}
104104

105-
// 显示列不存在时 不显示
106-
if (ret && shownColumns != null && !shownColumns.Any(c => c.Equals(columnName, StringComparison.OrdinalIgnoreCase)))
105+
// 显示列存在时显示列
106+
if (ret && shownColumns != null && shownColumns.Any(c => c.Equals(columnName, StringComparison.OrdinalIgnoreCase)))
107107
{
108108
col.Visible = true;
109109
}

0 commit comments

Comments
 (0)