Example #1
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);
        }
Example #2
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);
        }
Example #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);
        }
Example #4
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);
        }
Example #5
0
 internal void SetGroup(GridViewGroup g)
 {
     this._group = g;
 }
Example #6
0
 public GridViewSummary(string col, CustomSummaryOperation op, SummaryResultMethod getResult, GridViewGroup grp)
     : this(col, String.Empty, op, getResult, grp)
 {
 }
Example #7
0
 public GridViewSummary(string col, SummaryOperation op, GridViewGroup grp) : this(col, String.Empty, op, grp)
 {
 }
Example #8
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);
        }