Skip to content

Commit cb8a7e2

Browse files
committed
revert: 撤销更新
1 parent d50f3c0 commit cb8a7e2

File tree

1 file changed

+4
-47
lines changed

1 file changed

+4
-47
lines changed

src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6-
using System.Collections;
76
using System.Globalization;
87

98
namespace BootstrapBlazor.Components;
@@ -175,57 +174,15 @@ public static List<IFilterAction> ToSearches(this IEnumerable<ITableColumn> colu
175174

176175
internal static RenderFragment RenderValue<TItem>(this ITableColumn col, TItem item) => builder =>
177176
{
178-
// 获取单元格数据
179177
var val = col.GetItemValue(item);
180-
// 当前类型是否为IEnumerable<>类型
181-
var isEnumerableValue = (Nullable.GetUnderlyingType(col.PropertyType) ?? col.PropertyType).IsGenericType && val is IEnumerable;
182-
183-
// 将IEnumerable<>转换为List<object>方法
184-
List<object> GetEnumeratorDatas(IEnumerable enumerableObj)
185-
{
186-
var enumerator = enumerableObj.GetEnumerator();
187-
var list = new List<object>();
188-
while (enumerator.MoveNext())
189-
{
190-
list.Add(enumerator.Current);
191-
}
192-
return list;
193-
}
194-
195178
if (col.Lookup != null && val != null)
196179
{
197-
// 如果存在Lookup数据转化 Lookup 数据源
198-
string? content = val.ToString();
199-
200-
if (isEnumerableValue && val is IEnumerable v)
180+
// 转化 Lookup 数据源
181+
var lookupVal = col.Lookup.FirstOrDefault(l => l.Value.Equals(val.ToString(), col.LookupStringComparison));
182+
if (lookupVal != null)
201183
{
202-
// 如果是 IEnumerable<> 类型数据,则先转化为 List<object> 类型
203-
var enumeratorDatas = GetEnumeratorDatas(v);
204-
205-
// 根据 List<object> 数据获取匹配数据
206-
var lookupVals = col.Lookup.Where(l => enumeratorDatas.Any(v1 => l.Value.Equals(v1?.ToString(), col.LookupStringComparison)));
207-
208-
if (lookupVals.Any())
209-
{
210-
//如果有匹配到数据,则将匹配的文本用,连接显示
211-
content = string.Join(",", lookupVals.Select(l => l.Text));
212-
}
213-
else
214-
{
215-
//如果未匹配到数据,则直接将原数据用,连接显示
216-
content = string.Join(",", enumeratorDatas);
217-
}
218-
}
219-
else
220-
{
221-
// 非IEnumerable<>类型数据直接通过ToString进行匹配
222-
var lookupVal = col.Lookup.FirstOrDefault(l => l.Value.Equals(val.ToString(), col.LookupStringComparison));
223-
if (lookupVal != null)
224-
{
225-
content = lookupVal.Text;
226-
}
184+
builder.AddContent(10, col.RenderTooltip(lookupVal.Text, item));
227185
}
228-
builder.AddContent(10, col.RenderTooltip(content, item));
229186
}
230187
else if (val is bool v1)
231188
{

0 commit comments

Comments
 (0)