Added maximum display length

This commit is contained in:
2025-01-28 10:11:35 +01:00
parent b288d58c5d
commit 193f334708
4 changed files with 38 additions and 11 deletions

View File

@@ -25,6 +25,7 @@ public class PropertyConfig(PropertyInfo info, TableConfig table, int nthPropert
public bool IsEnumerable { get; internal set; }
public bool IsListingProperty { get; set; }
public int Order { get; set; } = nthProperty;
public int DisplayLength { get; set; } = 32;
}
/// <summary>
@@ -190,4 +191,13 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
InnerConfig.Order = index;
return this;
}
/// <summary>
/// Sets the maximum character length displayed in the admin ui (not in the editor dialog)
/// </summary>
/// <param name="maxLength">The maximum length of characters to be displayed</param>
public PropertyConfigurator<TProp> SetDisplayLength(int maxLength) {
InnerConfig.DisplayLength = maxLength;
return this;
}
}

View File

@@ -54,7 +54,7 @@
@foreach (var property in _config!.Properties.Where(prop => prop.List).OrderBy(prop => prop.Order)) {
<PropertyColumn
Title="@property.Name" Property="o => _manager!.DisplayProperty(o, property, null).Result"
Title="@property.Name" Property="o => DisplayProperty(property, o).Result"
Style="min-width: max-content; height: 44px;"
Sortable="@property.Sortable"/>
}
@@ -283,4 +283,13 @@
_allSelected = selected;
}
private async Task<string> DisplayProperty(PropertyConfig config, object entry) {
var display = await _manager!.DisplayProperty(entry, config);
if (display.Length > config.DisplayLength)
display = display.Substring(0, config.DisplayLength) + "...";
return display;
}
}