Skip to content

Commit cc9ac4f

Browse files
authored
perf(table): only call once OnQuery when set ScrollMode to Virtual (#8071)
* refactor: 代码重构 * chore: bump version 10.7.0
1 parent 1a30a62 commit cc9ac4f

2 files changed

Lines changed: 13 additions & 4 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.5-beta01</Version>
4+
<Version>10.7.0</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,15 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
11341134
SortOrder = col.DefaultSortOrder;
11351135
}
11361136

1137-
// 调用查询方法渲染 UI
1138-
await QueryAsync(true, 1, false, true, IsAutoQueryFirstRender);
1137+
if (ScrollMode == ScrollMode.None)
1138+
{
1139+
// 调用查询方法渲染 UI
1140+
await QueryAsync(true, 1, false, true, IsAutoQueryFirstRender);
1141+
}
1142+
else
1143+
{
1144+
StateHasChanged();
1145+
}
11391146
return;
11401147
}
11411148

@@ -1750,13 +1757,15 @@ void SetEditTemplate()
17501757
public Dictionary<string, IFilterAction> Filters { get; } = [];
17511758
#endregion
17521759

1760+
private bool isFirstQuery = true;
17531761
private async ValueTask<ItemsProviderResult<TItem>> LoadItems(ItemsProviderRequest request)
17541762
{
17551763
StartIndex = _shouldScrollTop ? 0 : request.StartIndex;
17561764
_pageItems = request.Count;
17571765

17581766
await ToggleLoading(true);
1759-
await QueryData();
1767+
await QueryData(triggerByPagination: false, firstQuery: isFirstQuery);
1768+
isFirstQuery = false;
17601769
await ToggleLoading(false);
17611770

17621771
return new ItemsProviderResult<TItem>(QueryItems, TotalCount);

0 commit comments

Comments
 (0)