Esempio n. 1
0
 public GridViewSummary(string col, string formatString, SummaryOperation op, GridViewGroup grp)
     : this(col, grp)
 {
     this._formatString = formatString;
     this._operation = op;
     this._customOperation = null;
     this._getSummaryMethod = null;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 private GridViewSummary(string col, GridViewGroup grp)
 {
     this._column = col;
     this._group = grp;
     this._value = null;
     this._quantity = 0;
     this._automatic = true;
     this._treatNullAsZero = false;
 }
Esempio n. 4
0
 public GridViewSummary(string col, CustomSummaryOperation op, SummaryResultMethod getResult, GridViewGroup grp)
     : this(col, String.Empty, op, getResult, grp)
 {
 }
Esempio n. 5
0
 public GridViewSummary(string col, SummaryOperation op, GridViewGroup grp)
     : this(col, String.Empty, op, grp)
 {
 }
Esempio n. 6
0
 internal void SetGroup(GridViewGroup g)
 {
     this._group = g;
 }
Esempio n. 7
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;
        }
Esempio n. 8
0
        private void ProcessGroup(GridViewGroup g, GridViewRowEventArgs e)
        {
            string groupHeaderText = String.Empty;

            // Check if it's still in the same group values
            if (!EvaluateEquals(g, e.Row.DataItem)) {
                // Check if a group ends or if it is the first group values starting...
                if (g.ActualValues != null) {
                    g.CalculateSummaries();
                    GenerateGroupSummary(g, e.Row);

                    // Triggers event GroupEnd
                    if (GroupEnd != null) {
                        GroupEnd(g.Name, g.ActualValues, e.Row);
                    }
                }

                // Another group values starts now
                g.Reset();
                g.SetActualValues(GetGroupRowValues(g, e.Row.DataItem));

                // If group is automatic inserts a group header
                if (g.Automatic) {
                    for (int v = 0; v < g.ActualValues.Length; v++) {
                        if (g.ActualValues[v] == null) continue;
                        groupHeaderText += g.ActualValues[v].ToString();
                        if (g.ActualValues.Length - v > 1) {
                            groupHeaderText += " - ";
                        }
                    }

                    GridViewRow newRow = InsertGridRow(e.Row);
                    newRow.Cells[0].Text = groupHeaderText;

                    // Triggers event GroupHeader
                    if (GroupHeader != null) {
                        GroupHeader(g.Name, g.ActualValues, newRow);
                    }
                }

                // Triggers event GroupStart
                if (GroupStart != null) {
                    GroupStart(g.Name, g.ActualValues, e.Row);
                }
            }

            g.AddValueToSummaries(e.Row.DataItem);
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        private object[] GetGroupRowValues(GridViewGroup g, object dataitem)
        {
            object[] values = new object[g.Columns.Length];

            for (int i = 0; i < g.Columns.Length; i++) {
                values[i] = DataBinder.Eval(dataitem, g.Columns[i]);
            }

            return values;
        }
Esempio n. 11
0
        /// <summary>
        /// Compares the actual group values with the values of the current dataitem
        /// </summary>
        /// <param name="g"></param>
        /// <param name="dataitem"></param>
        /// <returns></returns>
        private bool EvaluateEquals(GridViewGroup g, object dataitem)
        {
            // The values wasn't initialized
            if (g.ActualValues == null) return false;

            for (int i = 0; i < g.Columns.Length; i++) {
                if (g.ActualValues[i] == null && DataBinder.Eval(dataitem, g.Columns[i]) != null) return false;
                if (g.ActualValues[i] != null && DataBinder.Eval(dataitem, g.Columns[i]) == null) return false;
                if (!g.ActualValues[i].Equals(DataBinder.Eval(dataitem, g.Columns[i]))) return false;
            }

            return true;
        }
Esempio n. 12
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;
        }
Esempio n. 13
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;
        }
Esempio n. 14
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;
        }
Esempio n. 15
0
        public GridViewGroup RegisterGroup(string[] columns, bool auto, bool hideGroupColumns)
        {
            if (HasSuppressGroup()) {
                throw new Exception(SUPPRESS_GROUP_ALREADY_DEFINED);
            }

            // TO DO: Perform column validation...
            GridViewGroup g = new GridViewGroup(columns, auto, hideGroupColumns);
            mGroups.Add(g);

            if (hideGroupColumns) {
                for (int i = 0; i < mGrid.Columns.Count; i++) {
                    for (int j = 0; j < columns.Length; j++) {
                        if (GetDataFieldName(mGrid.Columns[i]).ToLower() == columns[j].ToLower()) {
                            mGrid.Columns[i].Visible = false;
                        }
                    }
                }
            }

            return g;
        }