Skip to content

Commit dd38958

Browse files
authored
refactor(Table): remove observeHeight method (#8026)
* refactor: 移除 observeHeight 脚本修复报错问题 * refactor: init 方法时 _tableColumnStates 为空移除此变量 * refactor: 增加未设置列宽客户端调整逻辑 * chore: bump version 10.6.1
1 parent 18056d5 commit dd38958

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

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.6.1-beta24</Version>
4+
<Version>10.6.1</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,6 @@ private async Task OnTableRenderAsync(bool firstRender)
14051405
FitColumnWidthIncludeHeader,
14061406
ResizeColumnCallback = nameof(ResizeColumnCallback),
14071407
ColumnMinWidth = ColumnMinWidth ?? Options.CurrentValue.TableSettings.ColumnMinWidth,
1408-
ColumnStates = _tableColumnStates,
14091408
ScrollWidth = ActualScrollWidth,
14101409
ShowColumnWidthTooltip,
14111410
ColumnWidthTooltipPrefix,

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ const check = table => {
175175
cancelAnimationFrame(table.loopCheckHeightHandler);
176176
delete table.loopCheckHeightHandler;
177177
}
178-
observeHeight(table);
179178
}
180179
};
181180

@@ -954,12 +953,25 @@ const getLocalStorageValue = key => {
954953

955954
const getColumnStateObject = table => {
956955
const cols = table.options.columnStates;
956+
if (cols !== void 0) {
957+
return {
958+
cols: cols.map(col => {
959+
return {
960+
name: col.name,
961+
width: getColumnWidth(col, table.columns),
962+
visible: col.visible
963+
}
964+
}),
965+
table: getTableWidth(table.tables[0])
966+
};
967+
}
968+
957969
return {
958-
cols: cols.map(col => {
970+
cols: table.columns.map(col => {
959971
return {
960-
name: col.name,
961-
width: getColumnWidth(col, table.columns),
962-
visible: col.visible
972+
name: col.getAttribute('data-bb-field'),
973+
width: getWidth(col.closest('th')) | 0,
974+
visible: true
963975
}
964976
}),
965977
table: getTableWidth(table.tables[0])

0 commit comments

Comments
 (0)