@@ -178,14 +178,13 @@ public static List<IFilterAction> ToSearches(this IEnumerable<ITableColumn> colu
178
178
/// <typeparam name="TItem"></typeparam>
179
179
/// <param name="col"></param>
180
180
/// <param name="item"></param>
181
- /// <param name="lookupService"></param>
182
181
/// <returns></returns>
183
- public static RenderFragment RenderValue < TItem > ( this ITableColumn col , TItem item , ILookupService lookupService ) => builder =>
182
+ public static RenderFragment RenderValue < TItem > ( this ITableColumn col , TItem item ) => builder =>
184
183
{
185
184
var val = col . GetItemValue ( item ) ;
186
185
if ( col . IsLookup ( ) && val != null )
187
186
{
188
- builder . AddContent ( 10 , col . RenderTooltip ( val . ToString ( ) , item , lookupService ) ) ;
187
+ builder . AddContent ( 10 , col . RenderLookupContent ( val . ToString ( ) , item ) ) ;
189
188
}
190
189
else if ( val is bool v1 )
191
190
{
@@ -221,7 +220,7 @@ public static RenderFragment RenderValue<TItem>(this ITableColumn col, TItem ite
221
220
{
222
221
content = val ? . ToString ( ) ;
223
222
}
224
- builder . AddContent ( 30 , col . RenderTooltip ( content , item , lookupService ) ) ;
223
+ builder . AddContent ( 30 , col . RenderLookupContent ( content , item ) ) ;
225
224
}
226
225
}
227
226
} ;
@@ -246,58 +245,59 @@ internal static RenderFragment RenderColor<TItem>(this ITableColumn col, TItem i
246
245
builder . CloseElement ( ) ;
247
246
} ;
248
247
249
- private static RenderFragment RenderTooltip < TItem > ( this ITableColumn col , string ? text , TItem item , ILookupService lookupService ) => pb =>
248
+ private static RenderFragment RenderLookupContent < TItem > ( this ITableColumn col , string ? text , TItem item ) => pb =>
250
249
{
251
250
if ( col . GetShowTips ( ) )
252
251
{
253
- pb . OpenComponent < Tooltip > ( 0 ) ;
254
- pb . SetKey ( item ) ;
255
- var tooltipText = text ;
256
- if ( col . GetTooltipTextCallback != null )
257
- {
258
- pb . AddAttribute ( 10 , nameof ( Tooltip . GetTitleCallback ) , new Func < Task < string ? > > ( ( ) => col . GetTooltipTextCallback ( item ) ) ) ;
259
- }
260
- else if ( col . IsLookup ( ) )
261
- {
262
- pb . AddAttribute ( 10 , nameof ( Tooltip . GetTitleCallback ) , new Func < Task < string ? > > ( async ( ) =>
263
- {
264
- var lookup = col . Lookup ?? await col . GetLookupService ( lookupService ) . GetItemsAsync ( col . LookupServiceKey , col . LookupServiceData ) ;
265
- return lookup ? . FirstOrDefault ( l => string . Equals ( l . Value , text , col . LookupStringComparison ) ) ? . Text ?? text ;
266
- } ) ) ;
267
- }
268
- else
269
- {
270
- pb . AddAttribute ( 11 , nameof ( Tooltip . Title ) , tooltipText ) ;
271
- }
272
- pb . AddAttribute ( 12 , "class" , "text-truncate d-block" ) ;
273
- if ( col . IsMarkupString )
274
- {
275
- pb . AddAttribute ( 13 , nameof ( Tooltip . ChildContent ) , new RenderFragment ( builder => builder . AddMarkupContent ( 0 , text ) ) ) ;
276
- pb . AddAttribute ( 14 , nameof ( Tooltip . IsHtml ) , true ) ;
277
- }
278
- else
279
- {
280
- pb . AddAttribute ( 15 , nameof ( Tooltip . ChildContent ) , new RenderFragment ( builder => builder . AddContent ( 0 , text ) ) ) ;
281
- }
282
- pb . CloseComponent ( ) ;
252
+ pb . AddContent ( 10 , col . RenderTooltip ( text , item ) ) ;
253
+ }
254
+ else
255
+ {
256
+ pb . AddContent ( 20 , col . RenderContent ( text ) ) ;
257
+ }
258
+ } ;
259
+
260
+ private static RenderFragment RenderTooltip < TItem > ( this ITableColumn col , string ? text , TItem item ) => pb =>
261
+ {
262
+ pb . OpenComponent < Tooltip > ( 0 ) ;
263
+ pb . SetKey ( item ) ;
264
+ if ( col . GetTooltipTextCallback != null )
265
+ {
266
+ pb . AddAttribute ( 10 , nameof ( Tooltip . GetTitleCallback ) , new Func < Task < string ? > > ( ( ) => col . GetTooltipTextCallback ( item ) ) ) ;
283
267
}
284
- else if ( col . IsLookup ( ) )
268
+ else
269
+ {
270
+ pb . AddAttribute ( 11 , nameof ( Tooltip . Title ) , text ) ;
271
+ }
272
+ if ( col . IsMarkupString )
273
+ {
274
+ pb . AddAttribute ( 12 , nameof ( Tooltip . IsHtml ) , true ) ;
275
+ }
276
+ pb . AddAttribute ( 13 , "class" , "text-truncate d-block" ) ;
277
+ pb . AddAttribute ( 14 , nameof ( Tooltip . ChildContent ) , col . RenderContent ( text ) ) ;
278
+ pb . CloseComponent ( ) ;
279
+ } ;
280
+
281
+ private static RenderFragment RenderContent ( this ITableColumn col , string ? text ) => pb =>
282
+ {
283
+ if ( col . IsLookup ( ) )
285
284
{
286
- pb . OpenComponent < LookupContent > ( 20 ) ;
287
- pb . AddAttribute ( 21 , nameof ( LookupContent . LookupService ) , col . LookupService ) ;
288
- pb . AddAttribute ( 22 , nameof ( LookupContent . LookupServiceKey ) , col . LookupServiceKey ) ;
289
- pb . AddAttribute ( 23 , nameof ( LookupContent . LookupServiceData ) , col . LookupServiceData ) ;
290
- pb . AddAttribute ( 24 , nameof ( LookupContent . LookupStringComparison ) , col . LookupStringComparison ) ;
291
- pb . AddAttribute ( 25 , nameof ( LookupContent . Value ) , text ) ;
285
+ pb . OpenComponent < LookupContent > ( 100 ) ;
286
+ pb . AddAttribute ( 101 , nameof ( LookupContent . LookupService ) , col . LookupService ) ;
287
+ pb . AddAttribute ( 102 , nameof ( LookupContent . LookupServiceKey ) , col . LookupServiceKey ) ;
288
+ pb . AddAttribute ( 103 , nameof ( LookupContent . LookupServiceData ) , col . LookupServiceData ) ;
289
+ pb . AddAttribute ( 104 , nameof ( LookupContent . LookupStringComparison ) , col . LookupStringComparison ) ;
290
+ pb . AddAttribute ( 105 , nameof ( LookupContent . Lookup ) , col . Lookup ) ;
291
+ pb . AddAttribute ( 106 , nameof ( LookupContent . Value ) , text ) ;
292
292
pb . CloseComponent ( ) ;
293
293
}
294
294
else if ( col . IsMarkupString )
295
295
{
296
- pb . AddMarkupContent ( 30 , text ) ;
296
+ pb . AddMarkupContent ( 110 , text ) ;
297
297
}
298
298
else
299
299
{
300
- pb . AddContent ( 40 , text ) ;
300
+ pb . AddContent ( 120 , text ) ;
301
301
}
302
302
} ;
303
303
0 commit comments