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

How to Change GridGroupHeaderItem Font Size?

3 Answers 222 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Radha
Top achievements
Rank 1
Radha asked on 05 Aug 2010, 01:17 PM
am attaching Screen shot...

in that Screen shot .How to change highlight Font Color
that he lighting line was using GridGroupByField ..

am using below code 


am using This Way ..
protected void rgMyFile_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridGroupHeaderItem)
        {
         
            (e.Item as GridGroupHeaderItem).Font.Size = FontUnit.Point(30);
            (e.Item as GridGroupHeaderItem).Font.Bold = true;
        }
    }
but its Not Working
protected void rgMyFile_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {

if (e.Item is GridGroupHeaderItem)
        {
            GridGroupHeaderItem item = e.Item as GridGroupHeaderItem;
             e.Item.Font.Size = FontUnit.Point(430);
            e.Item.Font.Bold = true;
            e.Item.CssClass = "rgGroupHeader";
        }
}

 <telerik:RadGrid ID="rgMyFile" runat="server"  ShowGroupPanel="false" AutoGenerateColumns="False" DataSourceID="odsMyFile" GridLines="None" EnableEmbeddedSkins="true"  Skin="Default" OnItemDataBound="rgMyFile_ItemDataBound"   OnItemCreated="rgMyFile_ItemCreated" ShowStatusBar="True" >
        <MasterTableView DataSourceID="odsMyFile"  ShowHeader="False">
               <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="SessionName" FieldName="SessionName" FormatString="{0:s}"
                                HeaderValueSeparator=" : " HeaderText=""></telerik:GridGroupByField>
                                 <telerik:GridGroupByField
            FieldName="CourseName"
            HeaderText="Course Name" FieldAlias="CourseName" FormatString=""/>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="SessionName" SortOrder="Descending" FieldAlias="SessionName" FormatString="" HeaderText=""></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                   
                </GroupByExpressions>
               
        <Columns >
                                    <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="File Name">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgbtn" runat="server" Width="20px" Height="20px" Enabled="false" />
                                                <asp:Label ID="fileType" runat="server" Text='<%#Eval("FileType") %>' ></asp:Label>
                                          </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                  
        </Columns>
        </MasterTableView>
      <GroupHeaderItemStyle CssClass ="rgGroupHeader" />
    </telerik:RadGrid>

using This way also not Working.
give me any solution

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Aug 2010, 02:37 PM
Hello,

Give a try with following code to customize the group header item.

Code behind:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
       if (e.Item is GridGroupHeaderItem)
        {
            GridGroupHeaderItem header = (GridGroupHeaderItem)e.Item;
            header.Style.Add("font-size", "30px");
        }
    }


-Shinu.
0
Sagar
Top achievements
Rank 1
answered on 13 Dec 2013, 05:43 AM
hi shinu

   i want to change color of group header as per condition. but in itemdataboud first execute for header n second time execute for GridDataItem, so i want to change color as per condition on GridDataItem, n apply on gruop header,


thanks
sagar
0
Angel Petrov
Telerik team
answered on 17 Dec 2013, 03:45 PM
Hello Sagar,

For achieving this goal you can subscribe to the PreRender event and traverse the items in order to check whether the relevant GridGroupHeaderItem should be colored or not. Later using the GetItems method you can obtain a reference to the headers and apply the styles.

I strongly suggest that you revise this help article which demonstrates a similar approach. The example does not follow the exact requirements but illustrates how you can reference the headers in the PreRender event which can help you in the process of implementation.

Regards,
Angel Petrov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Radha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sagar
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or