Ejemplo n.º 1
0
 private void FormartColumnsWithCheckHasParent(ICollection <ColumnItem> parents, ColumnItem column)
 {
     if (column != null && column.Parent != null)
     {
         if (column.Parent.Columns.Count == 0)
         {
             parents.Remove(column);
         }
     }
 }
Ejemplo n.º 2
0
        public Test1()
        {
            InitializeComponent();

            //绑定一个ComboBox数据源
            ObservableCollection <A> itemSource = new ObservableCollection <A>()
            {
                new A()
                {
                    Name = "左"
                },
                new A()
                {
                    Name = "中"
                },
                new A()
                {
                    Name = "右"
                }
            };

            ComboBoxDatas = itemSource;

            this.SaleDatas = Data2.CreateSaleData2s();


            //一级
            columns.Add(new ColumnItem("入库单号", "入库单号", "", "", HorizontalAlignment.Left, 130));
            columns.Add(new ColumnItem("金额", "金额", "", "", HorizontalAlignment.Left, 80));

            string moneyFormat = "{}{0:N2}";

            //一级
            var col = new ColumnItem("顶级标题");

            //二级,经此类推,不限级
            var quarter = new ColumnItem("二级标题", "dad");

            quarter.Columns.Add(new ColumnItem("三级标题", "Month1", "", moneyFormat, HorizontalAlignment.Right, 60));
            quarter.Columns.Add(new ColumnItem("三级标题", "Month2", "", moneyFormat, HorizontalAlignment.Right, 60));
            quarter.Columns.Add(new ColumnItem("三级标题", "Month3", "", moneyFormat, HorizontalAlignment.Right, 60));
            quarter.Columns.Add(new ColumnItem("三级标题", "Quarter1", "", moneyFormat, HorizontalAlignment.Right, 80));
            col.Columns.Add(quarter);

            quarter = new ColumnItem("二级标题", "asdas");
            quarter.Columns.Add(new ColumnItem("三级标题", "Month4", "", moneyFormat, HorizontalAlignment.Right, 60));
            quarter.Columns.Add(new ColumnItem("三级标题", "Month5", "", moneyFormat, HorizontalAlignment.Right, 60));
            quarter.Columns.Add(new ColumnItem("三级标题", "Month6", "", moneyFormat, HorizontalAlignment.Right, 60));
            quarter.Columns.Add(new ColumnItem("三级标题", "Quarter2", "", moneyFormat, HorizontalAlignment.Right, 80));
            col.Columns.Add(quarter);


            columns.Add(col);

            columns.Add(new ColumnItem("CheckBox类型", "Test", "", moneyFormat, HorizontalAlignment.Center, 80, ColumnType.CheckBox));

            this.dgList.AddBindingPathTemplateColumn(columns); //添加列集合

            OnLoadSetting(columns);
            this.dgList.ItemsSource = this.SaleDatas;
            //DataRowView rowView = this.dgList.SelectedItem as DataRowView;
            //if (rowView != null)
            //{
            //    var columnA = rowView.Row[0].ToString();  //传递索引
            //    var columnB = rowView.Row["columnname"].ToString(); //传递列名
            //}
        }
Ejemplo n.º 3
0
 private void FormartColumnsWithChild(ObservableCollection <ColumnItem> SettingDatas, ICollection <ColumnItem> parentColumns, ColumnItem parent)
 {
     //获取当前节点parent的子节点
     foreach (ColumnItem column in new List <ColumnItem>(parent.Columns))  //parent.Columns
     {
         //检测节点是否发生变化
         foreach (ColumnItem o in SettingDatas)
         {
             //当前节点的子节点包含子节点,再继续解析
             if (column.Columns.Count > 0)
             {
                 FormartColumnsWithChild(SettingDatas, parent.Columns, column);
             }
             if (o.ID == column.ID)
             {
                 if (o.Visibility == Visibility.Visible)
                 {
                     column.ExtendName = o.ExtendName;
                     column.Width      = o.Width;
                     column.Alignment  = o.Alignment;
                     column.Visibility = o.Visibility;
                 }
                 else
                 {
                     parent.Columns.Remove(column);
                 }
             }
         }
     }
     //当解析后,当前节点没有子节点时,移除父节点
     if (parent.Columns.Count == 0)
     {
         parentColumns.Remove(parent);
     }
 }