Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="detailGrid"></param>
        protected void CreateDetailGridSumRow(MyDetailGrid detailGrid)
        {
            bool needSum = false;

            if (!needSum)
            {
                foreach (Column column in detailGrid.Columns)
                {
                    GridColumnInfo info = column.Tag as GridColumnInfo;
                    if (info == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(info.StatFunction) || !Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    needSum = true;
                    break;
                }
            }

            if (needSum)
            {
                SummaryRow sumRow = detailGrid.AddSummaryRowToFixedFooter();
                sumRow.TextFormat = ADInfoBll.Instance.GetGridInfo(detailGrid.GridName).StatTitle;

                foreach (Column column in detailGrid.Columns)
                {
                    GridColumnInfo info = column.Tag as GridColumnInfo;
                    if (info == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(info.StatFunction) || !Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    MySummaryCell cell = ((MySummaryCell)sumRow.Cells[info.GridColumnName]);
                    cell.StatFunction          = BoundGridExtention.GetStatFunction(info.StatFunction);
                    cell.RunningStatGroupLevel = 0;
                    cell.ResultDataType        = typeof(string);

                    if (!string.IsNullOrEmpty(info.StatTitle))
                    {
                        cell.TitleFormat   = info.StatTitle;
                        cell.TitlePosition = TitlePosition.PreferablyRight;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 创建Summary行
        /// </summary>
        internal static void CreateSumRow(this IBoundGrid grid)
        {
            bool needSum = false;

            if (!string.IsNullOrEmpty(ADInfoBll.Instance.GetGridInfo(grid.GridName).StatTitle))
            {
                needSum = true;
            }
            if (!needSum)
            {
                foreach (Column column in grid.Columns)
                {
                    GridColumnInfo info = column.Tag as GridColumnInfo;
                    if (info == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(info.StatFunction) || !Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    needSum = true;
                    break;
                }
            }

            if (needSum)
            {
                SummaryRow sumRow = grid.AddSummaryRowToFixedFooter();

                sumRow.TextFormat = ADInfoBll.Instance.GetGridInfo(grid.GridName).StatTitle;

                foreach (Column column in grid.Columns)
                {
                    GridColumnInfo info = column.Tag as GridColumnInfo;
                    if (info == null || !Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    if (!string.IsNullOrEmpty(info.StatFunction))
                    {
                        MySummaryCell cell = ((MySummaryCell)sumRow.Cells[info.GridColumnName]);
                        cell.StatFunction          = BoundGridExtention.GetStatFunction(info.StatFunction);
                        cell.RunningStatGroupLevel = 0;
                        //cell.ResultDataType = typeof(string);

                        // 只有在StatFunction有效的时候,StatTitle才有效。就是一个常量型的文字
                        if (!string.IsNullOrEmpty(info.StatTitle))
                        {
                            //MySummaryCell cell = ((MySummaryCell)sumRow.Cells[info.GridColumnName]);
                            //cell.RunningStatGroupLevel = 0;
                            //cell.ResultDataType = typeof(string);
                            cell.TitleFormat   = info.StatTitle;
                            cell.TitlePosition = Xceed.Grid.TitlePosition.PreferablyRight;
                        }
                    }
                }
            }
        }