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

RadGrid HeaderImage with HeaderText

8 Answers 417 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 08 Jun 2010, 05:19 PM
Hi,

When I add a header image to a rad grid column the text disappears.  With the column code below I see the image but no text.  If I remove the HeaderImageUrl the text reappears. 

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn HeaderText="OPPE Forms Not Started" HeaderImageUrl="../images/notstarted.png" ItemStyle-CssClass="gridNumberColumns" DataField="FormsNotStarted" DataType="System.Int32"

 

 

 

UniqueName="FormsNotStarted">

 

 

 

</telerik:GridBoundColumn>

 

 

 

</Columns>

 

8 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 09 Jun 2010, 10:04 AM
Hi Eric,

A possible approach is to add a label to the control collection of the header item as shown below:
C#:
protected void PhoneBook_ItemDataBound(object sender, GridItemEventArgs e) 
    
        if (e.Item is GridHeaderItem) 
        
            GridHeaderItem header = (GridHeaderItem)e.Item; 
            Label lbl = new Label(); 
            lbl.Text = " OPPE Forms Not Started"
            header["FormsNotStarted"].Controls.AddAt(1, lbl); 
        
    }

Please give it a try and let me know if other questions or problems arise.

Regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Flippie
Top achievements
Rank 1
answered on 19 Jul 2010, 11:34 AM
Hi Pavlina,

I have the same problem as Eric and to keep things interesting I am also new to the RadControls.

Please be so kind as to explain your approach in a little bit more detail.
I understand that you create a class to add the label to the specific gridcoloumn.
What I don't understand is how this class will be called.

Sorry if this is a stupid Question...
I am still learning.

Regards,
Flippie
0
Pavlina
Telerik team
answered on 19 Jul 2010, 01:01 PM
Hello Flippie,

I suggest that you review the help article below which elaborates on this subject:
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Flippie
Top achievements
Rank 1
answered on 20 Jul 2010, 06:57 AM
Hi Pavlina,

I have noticed some strange behaviour.

1) When setting the HeaderStyle properties of a GridBoundColumn, a Font-Size change to have an impact on the newly added label but not the VerticalAlign property. The text stays at the bottom of the cell.

2) Setting any HeaderStyle property of a GridBinaryImageColumn has no impact on the newly added label.

3) Changing the newly added label properties in code override and produce the desired results expect for the vertical alignment of the text in the cell.

Any advice from your side to get the lbl text in the middle of the GridHeaderCell?

Regards,
Flippie
0
Pavlina
Telerik team
answered on 22 Jul 2010, 03:31 PM
Hello Flippie,

Could you paste your aspx and code-behind (please, use the code formatter tool of the ticket editor to make the code readable). 

Thanks.

Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nathan
Top achievements
Rank 1
answered on 30 Aug 2010, 02:54 PM
I would like to add an Image control along with the HeaderText in RadGrid. I can able to do this in ItemBound event. But is there any possible ways to do the same in page prerender event?
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2010, 05:41 AM
Hello Senthil,

Try the following code snippet in PreRender event to add an Image control along with the HeaderText.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       GridHeaderItem headerItem = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0];
       Image img = new Image();
       img.ImageUrl = "~/Images/Refresh.gif";
       headerItem["FirstName"].Controls.AddAt(1, img);
   }

Thanks,
Princy.
0
Nathan
Top achievements
Rank 1
answered on 31 Aug 2010, 01:18 PM
Thx much Princy. It worked.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Flippie
Top achievements
Rank 1
Nathan
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or