Esempio n. 1
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);
        }