标签:
数据库: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定义:
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 1; } } #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
DevExpress gridcontrol Master-Detail绑定到对象类型
标签:
原文地址:http://www.cnblogs.com/wdfrog/p/4249723.html