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

RadGrid with Grouping: Display icon next to group by name in Grid

3 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 10 Nov 2009, 05:33 AM

Hi,

I would like to display an icon next to group by column name with in grid with grouping feature.

Request you to please suggest.

Thanks and regards,

Manish Patel

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Nov 2009, 08:34 AM
Hello Manish,

You can try out the following code to add a control to your group header:
c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        CreateHeaderControls(e);        
    } 
    
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        CreateHeaderControls(e); 
    } 
 
    private void CreateHeaderControls(GridItemEventArgs e) 
    { 
 
        if (e.Item is GridGroupHeaderItem) 
        { 
            GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; 
            ImageButton imgBtn = new ImageButton(); 
            imgBtn.ID = "ImageBtn1";             
            imgBtn.ImageUrl = "Images/Image1.gif"
            imgBtn.Click += new ImageClickEventHandler(imgBtn_Click); 
            item.DataCell.Controls.Add(imgBtn); 
            
        }         
    } 
 
    void imgBtn_Click(object sender, ImageClickEventArgs e) 
    { 
        ImageButton imgBtn = (ImageButton)sender; 
        GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)imgBtn.NamingContainer; 
        groupHeader.Expanded = !groupHeader.Expanded; 
    } 

Thanks
Princy.
0
Manishkumar
Top achievements
Rank 1
answered on 12 Nov 2009, 05:07 AM
Hi,

Actually i dsiplay group name and then icon so ..suggested solution works for the first time but when i try to collapse the group then it displays like "Groupname#Imagepath" where # is separator for Groupnameand image path.

Request you to please suggest.

Thanks and regrads,
Manish
0
Sebastian
Telerik team
answered on 17 Nov 2009, 10:16 AM
Hello Manishkumar,

I think the solution provided by Princy in this thread should produce the desired result. Additionally, you can refer to the sample in this code library entry.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Manishkumar
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or