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

Button in the Group of gridview

1 Answer 75 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramraj
Top achievements
Rank 1
Ramraj asked on 28 Sep 2015, 03:26 PM

hi,

 

I have a grid view which has a grouping, I want to have a button within the group, is it possible, the image has been attached & I want a button next to

"Rule Name :Galaxy"

 

Thanks

Regards

Ramraj

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 29 Sep 2015, 02:36 PM
Hi Ramraj,

Thank you for writing.

You can create a custom GridGroupContentCellElement class, where you can add the button:
public class CustomCellElement : GridGroupContentCellElement
{
    public CustomCellElement(GridViewColumn column, GridRowElement row)
        : base(column, row)
    {
    }
 
    RadButtonElement buttonElement;
 
    protected override void CreateChildElements()
    {
        buttonElement = new RadButtonElement();
        buttonElement.Text = "testButton";
        buttonElement.StretchHorizontally = false;
        buttonElement.StretchVertically = false;
        buttonElement.Alignment = ContentAlignment.MiddleRight;
        this.Children.Add(buttonElement);
        base.CreateChildElements();
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(GridGroupContentCellElement);
        }
    }
}

You can use the CreateCell event to change the default cell element with the custom one:
void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
    if (e.CellType == typeof(GridGroupContentCellElement))
    {
        e.CellElement = new CustomCellElement(e.Column, e.Row);
    }       
}

I hope this will be useful.

Regards,
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Ramraj
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or