示例#1
0
        /// <summary>
        /// Hàm Test xử lý
        /// </summary>
        /// <param name="stt"></param>
        /// <param name="config"></param>
        /// <param name="bands"></param>
        private void ProcessCreateConfig(ColumnConfig config, GridBandCollection bands)
        {
            // Duyệt qua từng Brand
            for (int i = 0; i < bands.Count; i++)
            {
                // Khởi tạo một config column
                // Đưa vào config cha
                var tc = this.CreateColumnConfig(bands[i]);
                config.Columns.Add(tc);

                // Nếu có Brand con thì tiếp tục xử lý
                if (bands[i].HasChildren)
                {
                    ProcessCreateConfig(tc, bands[i].Children);
                }

                // Còn nếu không thì tạo config cho cột con
                else
                {
                    for (int j = 0; j < bands[i].Columns.Count; j++)
                    {
                        tc.Columns.Add(this.CreateColumnConfig(bands[i].Columns[j]));
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// CreateColumnConfig
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        protected ColumnConfig CreateColumnConfig(GridBand c)
        {
            var tc = new ColumnConfig(); tc.CopyValueFrom(c);

            tc.Visible = true;
            return(tc);
        }
示例#3
0
        protected override ColumnConfig DoProcess(ShBandedGridView t)
        {
            // Tạo config
            var config = new ColumnConfig();

            // Xử lý tạo config
            ProcessCreateConfig(config, t.Bands);

            // return
            return(config);
        }
示例#4
0
        /// <summary>
        /// CreateColumnConfig
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        protected ColumnConfig CreateColumnConfig(GridColumn c)
        {
            var cc = new ColumnConfig(); cc.CopyValueFrom(c);

            cc.DisplayFormat  = c.DisplayFormat;
            cc.SummaryItem    = c.SummaryItem;
            cc.AppearanceCell = c.AppearanceCell;
            if (cc.GroupIndex >= 0)
            {
                cc.Visible = true;
            }
            return(cc);
        }
示例#5
0
        private bool CheckVisible(ColumnConfig c)
        {
            if (c.Columns.Count > 0)
            {
                var total = 0;
                for (int i = 0; i < c.Columns.Count; i++)
                {
                    if (!CheckVisible(c.Columns[i]))
                    {
                        total++;
                    }
                }

                if (total == c.columns.Count)
                {
                    return(false);
                }
            }

            return(c.Visible);
        }
示例#6
0
        /// <summary>
        /// Tìm column
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        public IEnumerable <ColumnConfig> FindColumn(ColumnConfig column, bool first = true)
        {
            if (!first && column.Columns.Count == 0)
            {
                yield return(column);
            }

            else
            {
                foreach (var c in column.Columns)
                {
                    var min = FindColumn(c, false);
                    foreach (var cm in min)
                    {
                        yield return(cm);
                    }
                }
            }

            //var columns = column.Columns;
            //return columns.Concat(columns.SelectMany(ctrl => FindColumn(ctrl)));
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        private void DoGetColumns(Dictionary <int, List <ColumnRange> > dic, int row, ColumnConfig column, Dictionary <int, int> start)
        {
            List <ColumnRange> crs = null;

            if (!dic.ContainsKey(row))
            {
                dic[row] = crs = new List <ColumnRange>();
            }
            else
            {
                crs = dic[row];
            }

            if (!start.ContainsKey(row))
            {
                start[row] = 1;
            }

            var cr = new ColumnRange();

            cr.From = start[row];
            var totalColumns = FindColumn(column).Where(c => c.Visible);
            var countColumn  = totalColumns.Count();

            if (countColumn > 1)
            {
                cr.TotalMerge = start[row] + countColumn;
            }
            else
            {
                cr.TotalMerge = start[row] + countColumn;
            }

            cr.Width = totalColumns.Sum(c => c.Width);
            if (cr.Width == 0)
            {
                cr.Width = column.Width;
            }
            cr.Row          = 1;
            cr.ColumnConfig = column;
            crs.Add(cr);

            var beginRowAfter = start[row];

            // if (countColumn > 1) start[row] = cr.TotalMerge;
            if (countColumn >= 1)
            {
                start[row] = cr.TotalMerge;
            }
            else
            {
                start[row] = cr.TotalMerge + 1;
            }

            // Chỉ lấy những cột được hiển thị
            // var columnVisibles = column.Columns.Where(c => c.Visible).ToList();
            var columnVisibles = column.Columns.Where(c => CheckVisible(c)).ToList();

            for (int i = 0; i < columnVisibles.Count; i++)
            {
                if (!start.ContainsKey(row + 1))
                {
                    start[row + 1] = beginRowAfter;
                }
                DoGetColumns(dic, row + 1, columnVisibles[i], start);
            }
        }