示例#1
0
        internal void Validate()
        {
            if (Collection == null)
            {
                throw new RequiredPropertyException(nameof(Collection), this.GetType());
            }
            if (Columns == null)
            {
                throw new RequiredPropertyException(nameof(Columns), this.GetType());
            }
            else
            {
                foreach (var tgColumn in Columns)
                {
                    tgColumn.Validate();
                }
            }

            if (GroupOptions != null)
            {
                GroupOptions.Validate();

                if (Columns.All(it => it.PropertyName != GroupOptions.GetGroupingColumnName()))
                {
                    throw new IncorrectTgOptionsException("Columns must contain grouping property");
                }
            }
        }
示例#2
0
 internal void AddGroupColumnIfNotSet()
 {
     if (GroupOptions != null)
     {
         if (Columns.Count(it => it.PropertyName == GroupOptions.GetGroupingColumnName()) == 0)
         {
             IList <TgColumn> columns = Columns as IList <TgColumn>;
             columns.Insert(0, new TgColumn <T>
             {
                 Property  = GroupOptions.GroupingColumn,
                 AutoWidth = true,
                 Style     = new TgExcelStyle()
                 {
                     VerticalAlignment = ExcelVerticalAlignment.Center
                 }
             });
             Columns = columns;
         }
     }
 }