Grouping header is null?

4 posts, 0 answers
  1. Mark Smith
    Mark Smith avatar
    9 posts
    Member since:
    Oct 2012

    Posted 15 Sep 2011 Link to this post


    We're trying to group by a field called CompanyName. The grid seems to show the group but it creates a group per record. I tried hooked into the GroupSummaryEvaluate event and when I look at the e.Value it's null?

    If I remove the grouping I can see that CompanyName has values

    Why is it showing "CompanyName : " instead of "CompanyName : Some Company Name" ?
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 15 Sep 2011 Link to this post

    Hello Mark,

    Could you please tell me what is the type for the CompanyName? string? is it a data bound column?

    For more info on grouping please take a look at this help article.

    If you are still having problems, please create a small sample and post it here and i will do my best to help you solve this issue.

    Best Regards,
    Emanuel Varga
  3. Renate
    Renate avatar
    4 posts
    Member since:
    Nov 2011

    Posted 06 Jan 2012 Link to this post

    Hello Emanuael,

    I have a similar problem as Mark, but for custom grouping only:

    1. grid.EnableCustomGrouping= true;

    2. in grid_CustomGrouping  a new GroupKey is set for 1 column because I want to sort by another (hidden) column:
        e.GroupKey = <value_of_some_other_column>;

    3. In the grid_GroupSummaryEvaluate event

        a) e.Value and e.Group.Header are set for non-custom-group columns but
        b) both are null for the custom-group column, so the group header only consists of the column name plus ':',
             e.g. "CompanyName : " instead of "CompanyName : Some Company Name"
    Is there anything else I have to do in the grid_CustomGrouping event?

    Hope you can help me with ths

    best regards


  4. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 11 Jan 2012 Link to this post

    Hi Renate,

    In this custom grouping scenario you can use e.Group.Key value to format the header in GorupSummaryEvaluate event handler. Here is a codebase of our Demo application for custom grouping:

    public partial class Form1 : ExamplesForm
            public Form1()
                this.radGridView.EnableGrouping = true;
                this.radGridView.EnableCustomGrouping = true;
                this.radGridView.ShowGroupedColumns = true;
                this.radGridView.GroupSummaryEvaluate += new GroupSummaryEvaluateEventHandler(radGridView_GroupSummaryEvaluate);
                this.radGridView.ViewRowFormatting += new RowFormattingEventHandler(radGridView_ViewRowFormatting);
            private void SetConditions()
                ConditionalFormattingObject c3 = new ConditionalFormattingObject("Grey, applied to cell", ConditionTypes.NotEqual, "Germany", "", false);
                c3.RowBackColor = Color.FromArgb(169, 183, 201);
                c3.CellBackColor = Color.FromArgb(169, 183, 201);
                ConditionalFormattingObject c1 = new ConditionalFormattingObject("Blue , applied to cell", ConditionTypes.Equal, "Germany", "", false);
                c1.RowBackColor = Color.FromArgb(163, 191, 226);
                c1.CellBackColor = Color.FromArgb(163, 191, 226);
                ConditionalFormattingObject c2 = new ConditionalFormattingObject("LightPurple, applied to cell", ConditionTypes.Equal, "France", "", false);
                c2.RowBackColor = Color.FromArgb(212, 210, 241);
                c2.CellBackColor = Color.FromArgb(212, 210, 241);
            private void radGridView1_CustomGrouping(object sender, GridViewCustomGroupingEventArgs e)
                if (this.UseDefaultGrouping(e.Level))
                    e.Handled = false;
                int color = Color.White.ToArgb();
                int columnIndex = this.radGridView.Columns["Country"].Index;
                ConditionalFormattingObjectCollection conditions = this.radGridView.Columns[columnIndex].ConditionalFormattingObjectList;
                for (int i = 0; i < conditions.Count; i++)
                    if (conditions[i].Evaluate(e.Row, this.radGridView.Columns["Country"]))
                        color = conditions[i].CellBackColor.ToArgb();
                e.GroupKey = color;
            private bool UseDefaultGrouping(int level)
                GroupDescriptor groupDescriptor = this.radGridView.GroupDescriptors[level];
                for (int i = 0; i < groupDescriptor.GroupNames.Count; i++)
                    if (groupDescriptor.GroupNames[i].PropertyName.Equals("Country", StringComparison.InvariantCultureIgnoreCase))
                        return false;
                return true;
            void radGridView_ViewRowFormatting(object sender, RowFormattingEventArgs e)
                GridViewGroupRowInfo groupRow = e.RowElement.RowInfo as GridViewGroupRowInfo;
                if (groupRow != null && groupRow.Group.Key is int)
                    e.RowElement.BackColor = Color.FromArgb((int)groupRow.Group.Key);
            void radGridView_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
                if (this.UseDefaultGrouping(e.Group.Level))
                e.FormatString = this.GetColorName(e.Group.Key.ToString());
            private string GetColorName(string p)
                switch (p)
                    case "-6045726":
                        return "Blue";
                    case "-5654583":
                        return "Grey";
                    case "-2829583":
                        return "LightPurple";
                        return "White";
            private void OnFormLoad(object sender, EventArgs e)
                this.radGridView.GroupDescriptors.Expression = "Country";
                this.SelectedControl = this.radGridView;
            protected override string GetExampleDefaultTheme()
                return "ControlDefault";

    I hope this helps. Let me know if you need further assistance.

    Julian Benkov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top