Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
72ffffa
Table组件能否新增动态设置固定列的功能
Tony-ST0754 Jun 12, 2026
74435e6
清除空行,增加缓存列可能为判断
Tony-ST0754 Jun 12, 2026
d2b7775
refactor: 补充动态固定列时,没有列宽给默认列宽
Tony-ST0754 Jun 12, 2026
02a3fac
补充单元测试
Tony-ST0754 Jun 12, 2026
3398898
清除多余空行
Tony-ST0754 Jun 12, 2026
0958204
补充固定列持久化回来时style上的值不正确
Tony-ST0754 Jul 7, 2026
2dd7992
doc(Localization): add SearchFormLocalizerOptions localization (#8112)
ArgoZhang Jun 12, 2026
b0997d6
fix(Table): use auto table layout when AllowResizing is enabled (#8113)
ArgoZhang Jun 13, 2026
781102a
feat(Utility): improve addLink method (#8116)
ArgoZhang Jun 14, 2026
d651f63
feat(Utility): improve addLink method (#8118)
ArgoZhang Jun 15, 2026
ee73d09
feat(DockView): bump version 10.0.15 (#8120)
ArgoZhang Jun 15, 2026
5ed381e
feat(DockView): bump version 10.0.16 (#8122)
ArgoZhang Jun 16, 2026
892e070
feat(Html2Pdf): bump version 10.0.9 (#8124)
ArgoZhang Jun 16, 2026
f172166
feat(Table): add auto width function (#8126)
ArgoZhang Jun 16, 2026
db8e375
feat(DockView): bump version 10.0.17 (#8128)
ArgoZhang Jun 17, 2026
67f07be
chore(LLMs): remove LLMs auto docs (#8130)
ArgoZhang Jun 18, 2026
4c525ae
feat(DockView): bump version 10.0.18 (#8132)
ArgoZhang Jun 18, 2026
d811fa9
feat(UniverSheet): bump version 10.0.14 (#8134)
ArgoZhang Jun 19, 2026
fc2fa3d
chore(LLMs): add LLMsDocsGenerator tool (#8136)
ArgoZhang Jun 20, 2026
3aeb67c
doc(NavMenu): update component category (#8138)
ArgoZhang Jun 21, 2026
9f70b5f
chore(Docs): update docs.json configuration file (#8140)
ArgoZhang Jun 21, 2026
10991e1
doc(Docs): update extensions components/services (#8142)
ArgoZhang Jun 22, 2026
f44940c
chore(LLMs): bump version 10.0.3 (#8144)
ArgoZhang Jun 22, 2026
9b777c4
fix(AutoComplete): skip filter when set SkipMatch to true (#8149)
ArgoZhang Jun 22, 2026
e2a8ed4
feat(DockView): make IsLock parameter work event set ShowLock to fals…
ArgoZhang Jun 23, 2026
2023878
doc(SvgIcon): update Href parameter doc (#8153)
ArgoZhang Jun 24, 2026
81d18e0
feat(SvgIcon): add custom class support (#8155)
ArgoZhang Jun 24, 2026
3cb9f71
feat(TreeViewItem): add IconTemplate parameter (#8157)
ArgoZhang Jun 24, 2026
568f404
test(TreeView): add IconTempalte unit test (#8160)
ArgoZhang Jun 24, 2026
9a27432
feat(Transfer): add OnDisabledCallback parameter (#8158)
ArgoZhang Jun 24, 2026
3e98780
Merge branch 'main' into feat-table-DynamicFixedColumn
ArgoZhang Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/BootstrapBlazor/Components/Table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ private void ResetTableColumns()
{
var item = _tableColumnStates[index];
var col = columnMap[item.Name];
col.Fixed = !string.IsNullOrEmpty(item.Name) && stateMap.TryGetValue(item.Name, out var state) ? stateMap[item.Name].Fixed : false;
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed
if (item.Visible)
Comment on lines 1485 to 1491
{
// 增加到可见列缓存集合
Expand All @@ -1449,7 +1450,8 @@ private void ResetTableColumns()
DisplayName = col.GetDisplayName(),
Name = col.GetFieldName(),
Width = col.Fixed && !col.Width.HasValue ? DefaultFixedColumnWidth : col.Width,
Visible = col.GetVisible(_screenSize)
Visible = col.GetVisible(_screenSize),
Fixed = col.Fixed
};

private async Task OnTableRenderAsync(bool firstRender)
Expand Down Expand Up @@ -1940,6 +1942,28 @@ public async Task FitAllColumnWidth()
await InvokeVoidAsync("fitAllColumnWidth", Id);
}

/// <summary>
/// <para lang="zh">更新表格列客户端状态方法</para>
/// <para lang="en">Update Table Column Client Status Method</para>
/// </summary>
/// <returns></returns>
public async Task<TableColumnClientStatus> UpdateTableColumnClientStatus()
{
if (Columns.Count != 0)
{
// 用户在外面变更了列状态后,为避免用户变更状态丢失,须将变更后的状态同步到缓存中
foreach (var item in Columns)
{
_tableColumnStates.Find(x => x.Name == item.GetFieldName())!.Fixed = item.Fixed;
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
}
StateHasChanged();
}
// 如果启用了 ClientTableName 则更新浏览器持久化列状态
await InvokeVoidAsync("updateColumnStates", Id);

return _tableColumnStateCache;
}
Comment on lines +2003 to +2023

/// <summary>
/// <para lang="zh">清除表格列客户端状态实例方法</para>
/// <para lang="en">clear table column client status instance method</para>
Expand Down
20 changes: 17 additions & 3 deletions src/BootstrapBlazor/Components/Table/Table.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ const autoFitColumnWidth = async (table, col) => {
const index = indexOfCol(col);
let rows = null;
let maxWidth = getColumnMaxCellWidth(table, index);

if (table.options.fitColumnWidthIncludeHeader) {
const th = getColumnHeader(col);
maxWidth = Math.max(maxWidth, getCellWidth(th));
Expand Down Expand Up @@ -936,6 +936,18 @@ const removeColumnWidthState = tableName => {
localStorage.removeItem(columnWidthKey);
}

export function updateColumnStates(id) {
const el = document.getElementById(id)
if (el === null) {
return
}
let table = Data.get(id)
table.el = el;
Data.set(id, table)
const state = getColumnStateObject(table);
saveColumnStateToLocalstorage(table, state);

}
Comment on lines +973 to +983
export function clearColumnStates(tableName) {
const columnStateKey = `bb-table-${tableName}`;
localStorage.removeItem(columnStateKey);
Expand Down Expand Up @@ -976,7 +988,8 @@ const getColumnStateObject = table => {
return {
name: col.name,
width: getColumnWidth(col, table.columns),
visible: col.visible
visible: col.visible,
fixed: col.fixed
}
}),
table: getTableWidth(table.tables[0])
Expand All @@ -988,7 +1001,8 @@ const getColumnStateObject = table => {
return {
name: getColumnName(col),
width: getResizableColumnWidth(col),
visible: true
visible: true,
fixed: getColumnHeader(col).classList.contains('fixed')
}
}),
table: getTableWidth(table.tables[0])
Expand Down
6 changes: 6 additions & 0 deletions src/BootstrapBlazor/Components/Table/TableColumnState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public class TableColumnState
/// <para lang="en">Gets or sets column width</para>
/// </summary>
public int? Width { get; set; }

/// <summary>
/// <para lang="zh">获得/设置 列固定</para>
/// <para lang="en">Gets or sets column fixed</para>
/// </summary>
public bool Fixed { get; set; }
}
49 changes: 49 additions & 0 deletions test/UnitTest/Components/TableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9018,6 +9018,55 @@
Assert.NotNull(clientState);
}

[Fact]
public async Task UpdateTableColumnClientStatus_Ok()
{
var state = new TableColumnClientStatus();
state.TableWidth = 220;
state.Columns.Add(new TableColumnState() { Name = nameof(Foo.Name), Visible = true, Width = 100, Fixed = true });
state.Columns.Add(new TableColumnState() { Name = nameof(Foo.Address), Visible = true, Width = 120, Fixed = false });

Context.JSInterop.Setup<TableColumnClientStatus>("getColumnStates", "test_update").SetResult(state);
var invoker = Context.JSInterop.SetupVoid("clearColumnStates", "test_update");
invoker.SetVoidResult();

var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
var cut = Context.Render<BootstrapBlazorRoot>(pb =>
{
pb.AddChildContent<Table<Foo>>(pb =>
{
pb.Add(a => a.ClientTableName, "test_update");
pb.Add(a => a.RenderMode, TableRenderMode.Table);
pb.Add(a => a.AllowResizing, true);
pb.Add(a => a.OnQueryAsync, OnQueryAsync(localizer));
Comment on lines +9040 to +9045
pb.Add(a => a.TableColumns, foo => builder =>
{
builder.OpenComponent<TableColumn<Foo, string>>(0);
builder.AddAttribute(1, "Field", "Name");
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
builder.AddAttribute(3, "Width", 80);
builder.CloseComponent();

builder.OpenComponent<TableColumn<Foo, string>>(0);
builder.AddAttribute(3, "Field", "Address");
builder.AddAttribute(4, "FieldExpression", Utility.GenerateValueExpression(foo, "Address", typeof(string)));
builder.CloseComponent();
});
});
});

// 由于启用了客户端持久化 Name 列宽使用 100 而非 80
var table = cut.FindComponent<Table<Foo>>();
var colGroup = table.Find("colgroup");
Assert.Contains("style=\"width: 100px;\"", colGroup.ToMarkup());
Assert.Contains("style=\"width: 120px;\"", colGroup.ToMarkup());


var status = await cut.InvokeAsync(() => table.Instance.UpdateTableColumnClientStatus());
Assert.Equal(true, status.Columns[0].Fixed);

Check warning on line 9066 in test/UnitTest/Components/TableTest.cs

View workflow job for this annotation

GitHub Actions / run test

Do not use Assert.Equal() to check for boolean conditions. Use Assert.True instead. (https://xunit.net/xunit.analyzers/rules/xUnit2004)
Assert.Equal(state.Columns.Count, status.Columns.Count);
}

[Fact]
public async Task ClearTableColumnClientStatus_Ok()
{
Expand Down
Loading