Button in the Group of gridview

2 posts, 0 answers
  1. Ramraj
    Ramraj avatar
    3 posts
    Member since:
    Sep 2015

    Posted 28 Sep 2015 Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 29 Sep 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top