You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/Infrastructure/Views/Shared/_Index_Row.cshtml

26 lines
1.1 KiB

@using System.Reflection
@using Microsoft.AspNetCore.Mvc.Controllers
@using Infrastructure.Web.Mvc
@using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
@{
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml && !pm.IsComplexType && !pm.IsCollectionType);
}
@{
foreach (var prop in props)
{
var metadata = prop as DefaultModelMetadata;
if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId")
{
continue;
}
if (metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(SkipListAttribute)))
{
continue;
}
var templateName = prop.DataTypeName ?? prop.TemplateHint ?? (prop.ModelType == typeof(string) ? typeof(string).Name : null);
<td style="white-space: nowrap;text-overflow:ellipsis;overflow: hidden;max-width:10em;" data-ext="@templateName">
@Html.Display(prop.PropertyName, templateName)
</td>
}
}