Skip to content

Commit 0c81f10

Browse files
authored
refactor(Table): restore dynamic data type check logic (#8040)
* refactor: 恢复动态类型判断逻辑 * doc: 更新示例 * doc: 更新示例 * chore: bump version 10.6.3
1 parent 03f2385 commit 0c81f10

3 files changed

Lines changed: 20 additions & 16 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.2</Version>
4+
<Version>10.6.3</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ protected async Task QueryData(bool triggerByPagination = false, bool firstQuery
558558
var queryOption = BuildQueryPageOptions(firstQuery);
559559
queryOption.IsTriggerByPagination = triggerByPagination;
560560

561-
if (DynamicContext != null)
561+
562+
if (OnQueryAsync == null && typeof(TItem).IsAssignableTo(typeof(IDynamicObject)))
562563
{
563564
QueryDynamicItems(queryOption, DynamicContext, isAutoQuery);
564565
}

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,26 +1237,29 @@ private void ResetDynamicContext()
12371237
}
12381238
}
12391239

1240-
private void QueryDynamicItems(QueryPageOptions queryOption, IDynamicObjectContext context, bool isAutoQuery = true)
1240+
private void QueryDynamicItems(QueryPageOptions queryOption, IDynamicObjectContext? context, bool isAutoQuery = true)
12411241
{
12421242
if (isAutoQuery)
12431243
{
12441244
_rowsCache = null;
1245-
var items = context.GetItems();
1246-
if (context.OnFilterCallback != null)
1245+
if (context != null)
12471246
{
1248-
items = context.OnFilterCallback(queryOption, items);
1249-
}
1250-
if (IsPagination)
1251-
{
1252-
TotalCount = items.Count();
1253-
PageCount = (int)Math.Ceiling(TotalCount * 1.0 / Math.Max(1, _pageItems));
1254-
PageIndex = GetSafePageIndex();
1255-
items = items.Skip((PageIndex - 1) * _pageItems).Take(_pageItems);
1256-
}
1257-
QueryItems = items.Cast<TItem>().ToList();
1247+
var items = context.GetItems();
1248+
if (context.OnFilterCallback != null)
1249+
{
1250+
items = context.OnFilterCallback(queryOption, items);
1251+
}
1252+
if (IsPagination)
1253+
{
1254+
TotalCount = items.Count();
1255+
PageCount = (int)Math.Ceiling(TotalCount * 1.0 / Math.Max(1, _pageItems));
1256+
PageIndex = GetSafePageIndex();
1257+
items = items.Skip((PageIndex - 1) * _pageItems).Take(_pageItems);
1258+
}
1259+
QueryItems = items.Cast<TItem>().ToList();
12581260

1259-
ResetSelectedRows(QueryItems);
1261+
ResetSelectedRows(QueryItems);
1262+
}
12601263
}
12611264
}
12621265

0 commit comments

Comments
 (0)