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

header text and image

2 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ibrahim Imam
Top achievements
Rank 1
Ibrahim Imam asked on 03 May 2010, 05:13 PM
hello

i need to show text and an image in the header.
if i set the HeaderImageUrl only the picture is shown. i couldn't find a property or a thread so how can i avoid this behaviour or do i need a different approach at all?

best regards

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 May 2010, 06:56 AM

Hi Ibrahim,

Add the following code snippet in ItemCreated event to show image and text for grid header.

CS:

 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridHeaderItem)  
        {  
            GridHeaderItem headerItem = (GridHeaderItem)e.Item;  
            foreach(GridColumn column in RadGrid1.MasterTableView.Columns)  
            {  
                Literal lbl = new Literal();  
                lbl.Text = column.HeaderText;  
                headerItem[column.UniqueName].Controls.Add(lbl);  
            }  
        }  
    } 

[Add LinkButton with CommandName "Sort" instead of Literal, if you have enabled sorting and wants to sort on clicking the text]

-Shinu.

0
Ibrahim Imam
Top achievements
Rank 1
answered on 09 May 2010, 10:12 AM
thanks for your answer and the hint with the linkbutton.

i tried to add a link button with command sort but it was not working as expected.
there was a callback but no sorting occured so i added an image to the headeritem instead of the text.

image is shown and sorting still works with this solution.


Tags
Grid
Asked by
Ibrahim Imam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ibrahim Imam
Top achievements
Rank 1
Share this question
or