目前支持列表编辑方式主要有两种:非树形列表和树形列表
类图如下:
列表为ListEditor,树形列表TreeListEditor继承ListEditor。对应于各个属性编辑器有一个对应的GridColumn和TreeColumn,各个内部都引用了PropertyEditor。
下面分别对非树形和树形列表两种编辑方式进行简要说明,以便大家对它们的使用有所了解。
1 非树形列表
1.1 运行界面
1.2 类库编写
1.2.1 显示在主表列表中
[Serializable]
public partial class UnitFactorList : GBusinessListBase < UnitFactorList, UnitFactor >
{
region Factory Methods
region Data Access
region Business Methods
}
public partial class UnitFactorList : GBusinessListBase < UnitFactorList, UnitFactor >
{
region Factory Methods
region Data Access
region Business Methods
}
1.2.2 显示在细表中
private
static
PropertyInfo
<
PBSs
>
PBSsProperty
=
RegisterProperty( new PropertyInfo < PBSs > ( " PBSs " ));
[Association] //关联类型对象会自动在一个细表页签显示为列表类型
public PBSs PBSs
{
get
{
if ( ! FieldManager.FieldExists(PBSsProperty))
{
LoadProperty(PBSsProperty, PBSs.NewChild());
}
return GetProperty(PBSsProperty);
}
}
RegisterProperty( new PropertyInfo < PBSs > ( " PBSs " ));
[Association] //关联类型对象会自动在一个细表页签显示为列表类型
public PBSs PBSs
{
get
{
if ( ! FieldManager.FieldExists(PBSsProperty))
{
LoadProperty(PBSsProperty, PBSs.NewChild());
}
return GetProperty(PBSsProperty);
}
}
1.2.3 显示在下拉列表中
[Column]
[EntityProperty]
[ShowInList, ShowInDetail, Label( " 指标模板 " )]
[Lookup( "IndicatorType" )] //关联对象属性名称,此类型会自动生成下拉编辑方式
public Guid ? IndicatorTypeId
{
get { return GetProperty(IndicatorTypeIdProperty); }
set { SetProperty(IndicatorTypeIdProperty, value); }
}
[NotUndoable()]
private IndicatorType indicatorType;
public IndicatorType IndicatorType // 关联对象
{
get { return indicatorType; }
set { indicatorType = value; }
}
[EntityProperty]
[ShowInList, ShowInDetail, Label( " 指标模板 " )]
[Lookup( "IndicatorType" )] //关联对象属性名称,此类型会自动生成下拉编辑方式
public Guid ? IndicatorTypeId
{
get { return GetProperty(IndicatorTypeIdProperty); }
set { SetProperty(IndicatorTypeIdProperty, value); }
}
[NotUndoable()]
private IndicatorType indicatorType;
public IndicatorType IndicatorType // 关联对象
{
get { return indicatorType; }
set { indicatorType = value; }
}
2 树形列表
2.1 运行界面
2.2 类库编写
2.2.1 单个对象
[Serializable]
[Table]
[BusinessObject(Direction = Direction.Horizontal), Label( " PBS " )]
public class PBS : GBusinessBase < PBS > , ITreeNode //实现了ITreeNode的类会自动根据树形样式显示
{
...
}
[Table]
[BusinessObject(Direction = Direction.Horizontal), Label( " PBS " )]
public class PBS : GBusinessBase < PBS > , ITreeNode //实现了ITreeNode的类会自动根据树形样式显示
{
...
}
2.2.2 多个对象
private
static
PropertyInfo
<
CBFBFXBQItems
>
CBFBFXBQItemsProperty
=
RegisterProperty( new PropertyInfo < CBFBFXBQItems > ( " CBFBFXBQItems " ));
[Association(ShowInTree = true )] //ShowInTree为True时,子对象自动合并到父对象中显示为树形列表
public CBFBFXBQItems CBFBFXBQItems
{
get
{
if ( ! FieldManager.FieldExists(CBFBFXBQItemsProperty))
{
LoadProperty(CBFBFXBQItemsProperty, CBFBFXBQItems.NewChild());
}
return GetProperty(CBFBFXBQItemsProperty);
}
}
RegisterProperty( new PropertyInfo < CBFBFXBQItems > ( " CBFBFXBQItems " ));
[Association(ShowInTree = true )] //ShowInTree为True时,子对象自动合并到父对象中显示为树形列表
public CBFBFXBQItems CBFBFXBQItems
{
get
{
if ( ! FieldManager.FieldExists(CBFBFXBQItemsProperty))
{
LoadProperty(CBFBFXBQItemsProperty, CBFBFXBQItems.NewChild());
}
return GetProperty(CBFBFXBQItemsProperty);
}
}
树形样式和列表样式一样,可以显示在主表列表、细表和下拉列表类型中,这里就不再重复写出类库,下面只说明一下如何根据根对象PId来过滤树
2.2.3 指定树形列表根对象ID
有时下拉树中会要求过滤部分记录,需要指定根对象PId,类库编写如下:
private
static
PropertyInfo
<
Guid
?>
PBSIdProperty
=
RegisterProperty( new PropertyInfo < Guid ?> ( " PBSId " ));
[Column]
[EntityProperty]
[ShowInList, ShowInDetail, Label( " PBS " )]
[Lookup( " PBS " , DataSourceProperty = " ContractBudget.Contract.PBSList " ,
RootPId = " PBSRootPId " )]//RootPId指定树形显示过滤根对象PId
public Guid ? PBSId
{
get { return GetProperty(PBSIdProperty); }
set
{
SetProperty(PBSIdProperty, value);
...
}
}
/// <summary>
/// 如果父标题设置了PBS,则当前标题只显示父标题PBS的子PBS
/// </summary>
[Browsable( false )]
public object PBSRootPId
{
get
{
if (( null != parentNode) && ( null != parentNode.PBSId))
return parentNode.PBSId;
else
return null ;
}
}
[NotUndoable()]
private PBS pBS;
public PBS PBS
{
get { return pBS; }
set
{
pBS = value;
OnPropertyChanged( " PBS " );
}
}
RegisterProperty( new PropertyInfo < Guid ?> ( " PBSId " ));
[Column]
[EntityProperty]
[ShowInList, ShowInDetail, Label( " PBS " )]
[Lookup( " PBS " , DataSourceProperty = " ContractBudget.Contract.PBSList " ,
RootPId = " PBSRootPId " )]//RootPId指定树形显示过滤根对象PId
public Guid ? PBSId
{
get { return GetProperty(PBSIdProperty); }
set
{
SetProperty(PBSIdProperty, value);
...
}
}
/// <summary>
/// 如果父标题设置了PBS,则当前标题只显示父标题PBS的子PBS
/// </summary>
[Browsable( false )]
public object PBSRootPId
{
get
{
if (( null != parentNode) && ( null != parentNode.PBSId))
return parentNode.PBSId;
else
return null ;
}
}
[NotUndoable()]
private PBS pBS;
public PBS PBS
{
get { return pBS; }
set
{
pBS = value;
OnPropertyChanged( " PBS " );
}
}