Пример #1
0
        private void GenerateGroupSummary(GridViewGroup g, GridViewRow row)
        {
            int    colIndex;
            object colValue;

            if (!HasAutoSummary(g.Summaries) && !HasSuppressGroup())
            {
                return;
            }

            // Inserts a new row
            GridViewRow newRow = InsertGridRow(row, g);

            foreach (GridViewSummary s in g.Summaries)
            {
                if (s.Automatic)
                {
                    colIndex = GetVisibleColumnIndex(s.Column);
                    colIndex = ResolveCellIndex(newRow, colIndex);
                    newRow.Cells[colIndex].Text = this.GetFormatedString(s.FormatString, this.GetColumnFormat(GetColumnIndex(s.Column)), s.Value);
                }
            }

            // If it is a suppress group must set the grouped values in the cells
            // of the inserted row
            if (g.IsSuppressGroup)
            {
                for (int i = 0; i < g.Columns.Length; i++)
                {
                    colValue = g.ActualValues[i];
                    if (colValue != null)
                    {
                        colIndex = GetVisibleColumnIndex(g.Columns[i]);
                        colIndex = ResolveCellIndex(newRow, colIndex);
                        newRow.Cells[colIndex].Text = colValue.ToString();
                    }
                }
            }

            // Triggers event GroupSummary
            if (GroupSummary != null)
            {
                GroupSummary(g.Name, g.ActualValues, newRow);
            }
        }
Пример #2
0
        public GridViewGroup SetSuppressGroup(string[] columns)
        {
            if (mGroups.Count > 0)
            {
                throw new Exception(ONE_GROUP_ALREADY_REGISTERED);
            }

            // TO DO: Perform column validation...
            GridViewGroup g = new GridViewGroup(columns, true, false, false, false);

            mGroups.Add(g);

            // Disable paging because pager works in datarows that
            // will be suppressed
            mGrid.AllowPaging = false;

            return(g);
        }
Пример #3
0
        public GridViewSummary RegisterSummary(string column, string formatString, SummaryOperation operation, string groupName)
        {
            if (operation == SummaryOperation.Custom)
            {
                throw new Exception(USE_ADEQUATE_METHOD_TO_REGISTER_THE_SUMMARY);
            }

            GridViewGroup group = mGroups[groupName];

            if (group == null)
            {
                throw new Exception(String.Format(GROUP_NOT_FOUND, groupName));
            }

            // TO DO: Perform column validation...
            GridViewSummary s = new GridViewSummary(column, formatString, operation, group);

            group.AddSummary(s);

            return(s);
        }
Пример #4
0
        private bool ColumnHasSummary(string column, GridViewGroup g)
        {
            List <GridViewSummary> list;

            if (g == null)
            {
                list = this.mGeneralSummaries;
            }
            else
            {
                list = g.Summaries;
            }

            foreach (GridViewSummary s in list)
            {
                if (column.ToLower() == s.Column.ToLower())
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #5
0
        private bool ColumnHasSummary(int colindex, GridViewGroup g)
        {
            List <GridViewSummary> list;
            string column = this.GetDataFieldName(mGrid.Columns[colindex]);

            if (g == null)
            {
                list = this.mGeneralSummaries;
            }
            else
            {
                list = g.Summaries;
            }

            foreach (GridViewSummary s in list)
            {
                if (column.ToLower() == s.Column.ToLower())
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #6
0
        /// <summary>
        /// Inserts a grid row. Only cells required for the summary results
        /// will be created (except if GenerateAllCellsOnSummaryRow is true).
        /// The group will be checked for columns with summary
        /// </summary>
        /// <param name="beforeRow"></param>
        /// <param name="g"></param>
        /// <returns></returns>
        private GridViewRow InsertGridRow(GridViewRow beforeRow, GridViewGroup g)
        {
            int       colspan;
            TableCell cell;

            TableCell[] tcArray;
            int         visibleColumns = this.GetVisibleColumnCount();

            Table       tbl         = (Table)mGrid.Controls[0];
            int         newRowIndex = tbl.Rows.GetRowIndex(beforeRow);
            GridViewRow newRow      = new GridViewRow(newRowIndex, newRowIndex, DataControlRowType.DataRow, DataControlRowState.Normal);

            if (g != null && (g.IsSuppressGroup || g.GenerateAllCellsOnSummaryRow))
            {
                // Create all the table cells
                tcArray = new TableCell[visibleColumns];
                for (int i = 0; i < visibleColumns; i++)
                {
                    cell = new TableCell();
                    cell.ApplyStyle(mGrid.Columns[GetRealIndexFromVisibleColumnIndex(i)].ItemStyle);
                    cell.Text  = "&nbsp;";
                    tcArray[i] = cell;
                }
            }
            else
            {
                // Create only the required table cells
                colspan = 0;
                List <TableCell> tcc = new List <TableCell>();
                for (int i = 0; i < mGrid.Columns.Count; i++)
                {
                    if (ColumnHasSummary(i, g))
                    {
                        if (colspan > 0)
                        {
                            cell            = new TableCell();
                            cell.Text       = "&nbsp;";
                            cell.ColumnSpan = colspan;
                            tcc.Add(cell);
                            colspan = 0;
                        }

                        // insert table cell and copy the style
                        cell = new TableCell();
                        cell.ApplyStyle(mGrid.Columns[i].ItemStyle);
                        tcc.Add(cell);
                    }
                    else if (mGrid.Columns[i].Visible)
                    {
                        // A visible column that will have no cell because has
                        // no summary. So we increase the colspan...
                        colspan++;
                    }
                }

                if (colspan > 0)
                {
                    cell            = new TableCell();
                    cell.Text       = "&nbsp;";
                    cell.ColumnSpan = colspan;
                    tcc.Add(cell);
                    colspan = 0;
                }

                tcArray = new TableCell[tcc.Count];
                tcc.CopyTo(tcArray);
            }

            newRow.Cells.AddRange(tcArray);
            tbl.Controls.AddAt(newRowIndex, newRow);

            return(newRow);
        }
Пример #7
0
 internal void SetGroup(GridViewGroup g)
 {
     this._group = g;
 }
Пример #8
0
 public GridViewSummary(string col, CustomSummaryOperation op, SummaryResultMethod getResult, GridViewGroup grp)
     : this(col, String.Empty, op, getResult, grp)
 {
 }
Пример #9
0
 public GridViewSummary(string col, string formatString, CustomSummaryOperation op, SummaryResultMethod getResult, GridViewGroup grp)
     : this(col, grp)
 {
     this._formatString     = formatString;
     this._operation        = SummaryOperation.Custom;
     this._customOperation  = op;
     this._getSummaryMethod = getResult;
 }
Пример #10
0
 public GridViewSummary(string col, SummaryOperation op, GridViewGroup grp)
     : this(col, String.Empty, op, grp)
 {
 }