Cube/NewLife.CubeNC/ViewModels/FormField.cs

53 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace NewLife.Cube.ViewModels;
/// <summary>获取扩展字段委托</summary>
/// <param name="entity"></param>
/// <returns></returns>
public delegate Object GetExpandDelegate(Object entity);
/// <summary>表单字段</summary>
public class FormField : DataField
{
#if MVC
/// <summary>表单分组视图。MVC特有表单字段的分部视图名称不要.cshtml后缀。对标_Form_Group允许针对字段定义视图</summary>
public String GroupView { get; set; }
/// <summary>表单项视图。MVC特有表单字段的分部视图名称不要.cshtml后缀。对标_Form_Group允许针对字段定义视图</summary>
public String ItemView { get; set; }
#endif
/// <summary>获取扩展字段委托。当前字段所表示的对象,各属性作为表单字段展开</summary>
[Obsolete("=>Expand")]
public GetExpandDelegate GetExpand
{
get => Expand?.Decode == null ? null : e => Expand.Decode?.Invoke(e);
set
{
if (value == null)
{
if (Expand != null)
Expand.Decode = null;
}
else
{
var exp = Expand ??= new ExpandField();
exp.Decode = e => value(e);
}
}
}
/// <summary>保留扩展字段。默认false字段被扩展以后表单上就不再出现原字段</summary>
[Obsolete("=>Expand")]
public Boolean RetainExpand
{
get => Expand?.Retain ?? false;
set
{
if (Expand != null)
Expand.Retain = value;
}
}
/// <summary>扩展字段</summary>
public ExpandField Expand { get; set; }
}