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

GridView - Group Headers - Custom Template on GroupByExpression

5 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 02 Sep 2008, 11:09 AM
Hi,

Is there any way I can use a template field or something similar so that I can have a custom formatted entry above the group.  I can do this by adding a single entry into the select fields of the group by GroupByExpression object.. and then changing the format string to include a table with the format I need..

The problem with this is that I only have access to one field ({0}) which is the one referenced in the FieldName of the object.. but I need access to other fields returned by the data source.

Any suggestions?

Thanks

Mike

5 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 02 Sep 2008, 11:46 AM
Hello Michael,

This functionality is not readily supported by RadGrid, but you can always manually modify your GridGroupHeaderItem text to fit the data you need. This can be done in the ItemDataBound event of RadGrid, where you can get a reference to the GridGroupHeaderItem and mofiy its content:

void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridGroupHeaderItem) 
    { 
        GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; 
        item.DataCell.Text = item.DataCell.Text + " custom text";    
    } 

This way, your custom text would be any value you would need to reference in your grid data.

Kind regards,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 02 Sep 2008, 12:26 PM
Hi Veli,

That worked a treat.

Thanks very much.

Mike
0
Saravanan
Top achievements
Rank 1
answered on 08 Aug 2013, 01:59 PM
Hi,

i am using telerik radgrid in asp.net application, i have requirement to place some controls like (image with tool tip, dropdown,)in group header of each group in rad grid. please give suggestion for how to do that.

is it possible to place user control in group header of radgrid?

thanks

saravanan babu
0
Saravanan
Top achievements
Rank 1
answered on 08 Aug 2013, 02:02 PM
i am using telerik radgrid in asp.net application, i have requirement to place some controls (image with tooltip, lables, dopdown) in group header of radgrid. please suggest me how to do that.

is it possible to place asp.net  user control in radgrid group header?


thanks & regards

saravanan babu
0
Maria Ilieva
Telerik team
answered on 13 Aug 2013, 08:21 AM
Hi Saravanan,

Try the following code snippet in itemDataBound event to add controls to GroupHeaderItem.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridGroupHeaderItem)
            {
                GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
                Button objButton = new Button();
                  objButton.CommandName = "Add";
                objButton.ID = "Button_Add";
                item.DataCell.Controls.Add(objButton);
                item.DataCell.Style["text-align"] = "right";
            }
        }


Regards,
Maria Ilieva
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
Michael
Top achievements
Rank 1
Answers by
Veli
Telerik team
Michael
Top achievements
Rank 1
Saravanan
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or