数据库:C_ProductPlan ,C_ProductPlanItem
DTO定义:(实现每个计划条目-Master,对应多个ProcessInfo-Detail)

    [DataContract]
[Serializable]
public class PlanInfo:C_ProductPlan
{
public PlanInfo()
{
Items = new List<ProducePlanItem>();
} [DataMember]
public List<ProducePlanItem> Items { get; set; }
} [DataContract]
[Serializable]
public class ProducePlanItem :C_ProductPlanItem
{ public ProducePlanItem()
{
ProcessConfig = new List<ProcessInfo>();
} [DataMember]
public List<ProcessInfo> ProcessConfig { get; set; } } [Serializable]
public class ProcessInfo
{
public String Name{get;set;}
public int Order{get;set;}
public bool? IsChecked{get;set;}
public String Memo{get;set;}
}

UI定义:
index-是行记录,relationIndex是对应的子集合序号(可以有多个子集合),IsEmpty=true时主列表前面的"+"灰色
getCount 返回最大的子集合数

   public class ProducePlanItems : ArrayList, IRelationList
{
public ProducePlanItems()
{ } #region IRelationList 成员 public System.Collections.IList GetDetailList(int index, int relationIndex)
{
return this[index].ProcessConfig;
} public string GetRelationName(int index, int relationIndex)
{ return "ProcessConfig";
} public bool IsMasterRowEmpty(int index, int relationIndex)
{
return false;
} public int RelationCount
{
get { return ; }
} #endregion public virtual new ProducePlanItem this[int index]
{
get { return base[index] as ProducePlanItem; }
}
}

需要引用Dexexpress.Data.dll,

1.gridview-MainView 绑定到UI中定义的ProducePlanItems.

2.添加一个level1 将level1重命名称ProcessConfig(对应上面IRelationList.GetRelationName的返回
 
 3.level1 添加 gridview2 ,需要手动设置gridview的列,可以设置gridview2的ViewCaption

4.获取数据后将items转化成producePlanItems,并绑定到UI

05-07 09:26