I have in my model a ShortName attribute (expected to be "for the grid column label")
[MaxLength(256)]
[Display(Name = "Description", ShortName = "Desc.")]
public string Description { get; set; }
I use the DisplayFor
in the Grid header of the column, as indicated by documentation.
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
However, I see the "Description" in my column header, not "Desc." as expected.
I tried to do the MS does for DisplayName:
public static class HtmlHelperDisplayNameExtensions
{
public static string DisplayShortNameForModel(this IHtmlHelper htmlHelper)
{
if (htmlHelper == null)
{
throw new ArgumentNullException(nameof(htmlHelper));
}
return htmlHelper.DisplayShortNameForModel();
}
public static string DisplayShortNameFor<TModelItem, TResult>(
this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper,
Expression<Func<TModelItem, TResult>> expression)
{
if (htmlHelper == null)
{
throw new ArgumentNullException(nameof(htmlHelper));
}
if (expression == null)
{
throw new ArgumentNullException(nameof(expression));
}
// << ???? >>>>>>>
return htmlHelper.DisplayShortNameForInnerType(expression); // ??????
// << ???? >>>>>>>
// << ???? >>>>>>>
}
}
The DisplayShortNameForInnerType
unfortunalely does not exist