Skip to content

Commit 5232b64

Browse files
committed
refactor: 表格支持 Lookup 异步获取数据
1 parent 27b95b2 commit 5232b64

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,12 +1296,6 @@ protected RenderFragment GetValue(ITableColumn col, TItem item) => builder =>
12961296
}
12971297
else
12981298
{
1299-
if (col.Lookup == null && !string.IsNullOrEmpty(col.LookupServiceKey))
1300-
{
1301-
// 未设置 Lookup
1302-
// 设置 LookupService 键值
1303-
col.Lookup = LookupService.GetItemsByKey(col.LookupServiceKey, col.LookupServiceData);
1304-
}
13051299
builder.AddContent(20, col.RenderValue(item));
13061300
}
13071301
};

src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,9 @@ public static List<IFilterAction> ToSearches(this IEnumerable<ITableColumn> colu
175175
internal static RenderFragment RenderValue<TItem>(this ITableColumn col, TItem item) => builder =>
176176
{
177177
var val = col.GetItemValue(item);
178-
if (col.Lookup != null && val != null)
178+
if (col.IsLookup() && val != null)
179179
{
180-
// 转化 Lookup 数据源
181-
var lookupVal = col.Lookup.FirstOrDefault(l => l.Value.Equals(val.ToString(), col.LookupStringComparison));
182-
if (lookupVal != null)
183-
{
184-
builder.AddContent(10, col.RenderTooltip(lookupVal.Text, item));
185-
}
180+
builder.AddContent(10, col.RenderTooltip(val.ToString(), item));
186181
}
187182
else if (val is bool v1)
188183
{
@@ -253,6 +248,10 @@ private static RenderFragment RenderTooltip<TItem>(this ITableColumn col, string
253248
if (col.GetTooltipTextCallback != null)
254249
{
255250
pb.AddAttribute(10, nameof(Tooltip.GetTitleCallback), new Func<Task<string?>>(() => col.GetTooltipTextCallback(item)));
251+
}
252+
else if(col.IsLookup())
253+
{
254+
256255
}
257256
else
258257
{

0 commit comments

Comments
 (0)