Пример #1
0
        /// <summary>根据UISetting,自动添加网格列</summary>
        protected static void AddColumns(Grid grid, UISetting ui)
        {
            FineUI.GroupField group = null;
            foreach (var attr in ui.Settings)
            {
                // 跳过字段;跳过复杂字段(未实现);构建绑定列
                if (attr.Field.Name == "ID")
                {
                    continue;                           // 跳过ID字段
                }
                if (attr.ShowInGrid)
                {
                    // 根据 UIAttribute 创建绑定列
                    string formatString = GetDefaultFormatString(attr.Field.PropertyType);
                    if (!string.IsNullOrEmpty(attr.FormatString))
                    {
                        formatString = attr.FormatString;
                    }
                    var field = CreateBoundField(attr.Field.Name, attr.Title, formatString, attr.Width);

                    // 分组
                    if (string.IsNullOrEmpty(attr.Group))
                    {
                        grid.Columns.Add(field);
                    }
                    else
                    {
                        if (group != null && group.HeaderText == attr.Group)
                        {
                            group.Columns.Add(field);
                        }
                        else
                        {
                            group = new FineUI.GroupField()
                            {
                                HeaderText = attr.Group
                            };
                            group.Columns.Add(field);
                            grid.Columns.Add(group);
                        }
                    }
                }
            }
        }
Пример #2
0
 private void ResolveAllColumns(GroupField column)
 {
     foreach (GridColumn subColumn in column.Columns)
     {
         _allColumns.Add(subColumn);
         if (subColumn is GroupField)
         {
             ResolveAllColumns(subColumn as GroupField);
         }
     }
 }