码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress gridcontrol Master-Detail绑定到对象类型

时间:2015-01-26 11:45:24      阅读:1178      评论:0      收藏:0      [点我收藏+]

标签:

数据库: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;}
    }
View Code

 

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; }
        }
    }
View Code

需要引用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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!