This is a migrated thread and some comments may be shown as answers.

Radgrid Grouping Set more than one group header

3 Answers 275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dhamodharan
Top achievements
Rank 1
Dhamodharan asked on 26 Nov 2012, 01:53 PM
Hi,
I am using Radgrid with grouping. How i can group by two columns that should used in the <GroupHeaderTemplate> as following example.

I year  students                  ( Group by Year)

Science ( Group by Department)

Name

Student ID

 Avg mark

XXX

11111111

89

YYY

22222222

56

Maths ( Group by Department)

Name

Student ID

Avg mark

GGG

3333333

83

HHH

3333333

68

II year  students                  ( Group by Year)

Science ( Group by Department)

Name

Student ID

 Avg mark

XX

111111

99

YY

222222

87


Thanks

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 29 Nov 2012, 10:59 AM
Hello ,

Please try using multiple GroupExpressions:
<MasterTableView ...>
<GroupByExpressions>
    <telerik:GridGroupByExpression>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="Year"></telerik:GridGroupByField>
        </GroupByFields>
        <SelectFields>
            <telerik:GridGroupByField FieldName="Year"></telerik:GridGroupByField>
        </SelectFields>
    </telerik:GridGroupByExpression>
    <telerik:GridGroupByExpression>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="Department"></telerik:GridGroupByField>
        </GroupByFields>
        <SelectFields>
            <telerik:GridGroupByField FieldName="Department"></telerik:GridGroupByField>
        </SelectFields>
    </telerik:GridGroupByExpression>
</GroupByExpressions>

I hope this will prove helpful. Please give it a try and let me know about the result.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dhamodharan
Top achievements
Rank 1
answered on 29 Nov 2012, 11:27 AM
Hi Eyup,
       Thanks for your Solution. I have tried your solution, that satisfy the requirement of data, but what i need is Group by Column value to be shown as heading as follows. Year in the Middle with background color and the next Department in the middle with another background color.

                                               I year  students                  ( Group by Year)                                 

                                                           Science ( Group by Department)                                       

Name

Student ID

 Avg mark

XXX

11111111

89

YYY

22222222

56

                                                          Maths ( Group by Department)                                           

Name

Student ID

Avg mark

GGG

3333333

83

HHH

3333333

68

                                             II year  students                  ( Group by Year)                                   

                                                          Science ( Group by Department)                                        

Name

Student ID

 Avg mark

XX

111111

99

YY

222222

87



Thanks
0
Eyup
Telerik team
answered on 30 Nov 2012, 04:42 PM
Hi,

Please try the following approach:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridGroupHeaderItem)
    {
        GridGroupHeaderItem headerItem = e.Item as GridGroupHeaderItem;
        headerItem.HorizontalAlign = HorizontalAlign.Center;
        headerItem.BackColor = headerItem.GroupIndex.Contains("_") ? Color.LightBlue : Color.Orange;
    }
}

I hope this helps. Please give it a try and inform me about the result.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Dhamodharan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Dhamodharan
Top achievements
Rank 1
Share this question
or