PropertyInfo
参照TDatas
プロパティに従って、モデルのhtmlコードを返す次のメソッドがあります。
public MvcHtmlString GetHtml(HtmlHelper<TData> helper) {
if (PropertyInfo.IsDefined(typeof(UIHintAttribute), true)) {
UIHintAttribute uiHintAttribute = PropertyInfo.GetCustomAttributes(typeof(UIHintAttribute), true).Cast<UIHintAttribute>().FirstOrDefault();
if (uiHintAttribute != null) {
// Templatename ignored here
return helper.Display(PropertyInfo.Name, uiHintAttribute.UIHint);
}
}
return helper.Display(PropertyInfo.Name);
}
displaytemplate の名前は UIHint を介して定義され、正しく読み取られます。
したがって、1 つの呼び出しは次のようになります。
return helper.Display("Name", "NameDisplayTemplate");
残念ながら、templatename
特定の DisplayTemplate でプロパティをレンダリングする場合、パラメーターは無視されます。私はdisplaytemplate(フォルダdisplaytemplate)とpartialviewの両方を試しました。それらのどれも機能しませんでした。
誰かアイデアはありますか?