Extra buttons in GroupPanelElement

7 posts, 0 answers
  1. Hans
    Hans avatar
    15 posts
    Member since:
    Nov 2010

    Posted 19 Nov 2014 Link to this post

    Is it possible to add extra button to the GroupPanelElement of a radgridview?
    See attached picture.
    Hans Heuvelman
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3564 posts

    Posted 21 Nov 2014 Link to this post

    Hello Hans,

    Thank you for writing.

    In order to achieve your requirement, please have a look at the following code snippet:
    public Form1()
    {
        InitializeComponent();
     
        RadButtonElement exitButton = new RadButtonElement();
        exitButton.Text = "Exit";
        exitButton.MaxSize = new System.Drawing.Size(50, 20);
        exitButton.Click+=exitButton_Click;
        exitButton.Alignment = ContentAlignment.TopRight;
        this.radGridView1.GridViewElement.GroupPanelElement.Children.First().Children.First().Children.Add(exitButton);
    }

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Hans
    Hans avatar
    15 posts
    Member since:
    Nov 2010

    Posted 28 Nov 2014 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Most excellent. Thanks a lot.
    For simplicity I added a StackLayoutPanel to the grouppanel, and by buttons to the StackLayoutPanel.
  4. Hans
    Hans avatar
    15 posts
    Member since:
    Nov 2010

    Posted 28 Nov 2014 in reply to Hans Link to this post

    Now I would like to implement this in my custom_radgridview.
    Should I use the CreateCell event?  How do I then recognize when the grouppanel_cell is created?
  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3564 posts

    Posted 02 Dec 2014 Link to this post

    Hello Hans,

    Thank you for writing back.

    I am glad the suggested approach suits your requirement. In order to implement similar functionality in a custom RadGridView, you can create a custom RadGridViewElement and override the CreateGroupPanelElement method. Thus, you can add the desired elements after the GroupPanelElement is created:
    public class CustomGrid : RadGridView
    {
        public override string ThemeClassName 
        {
            get
            {
                return typeof(RadGridView).FullName; 
            }
        }
     
        protected override RadGridViewElement CreateGridViewElement()
        {
            return new CustomRadGridViewElement();
        }
    }
     
    public class CustomRadGridViewElement : RadGridViewElement
    {
        protected override Type ThemeEffectiveType    
        {
            get   
            {
                return typeof(RadGridViewElement);    
            }
        }
     
        protected override GroupPanelElement CreateGroupPanelElement()
        {
            GroupPanelElement groupPanel = base.CreateGroupPanelElement();
     
            RadButtonElement exitButton = new RadButtonElement();
            exitButton.Text = "Exit";
            exitButton.MaxSize = new System.Drawing.Size(50, 20);
            exitButton.Click += exitButton_Click;
            exitButton.Alignment = ContentAlignment.TopRight;
            groupPanel.Children.First().Children.First().Children.Add(exitButton);
            return groupPanel;
        }
     
        private void exitButton_Click(object sender, EventArgs e)
        {
            RadMessageBox.Show("Exit");
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Hans
    Hans avatar
    15 posts
    Member since:
    Nov 2010

    Posted 17 May 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    I used similar code in the constructor in 2015Q3 version (see code below), but in the 2017R2 version that breaks on 'rel.Children.Add(stackpanel);'

    How do I fix this ?

                _lblRecordCount = new RadLabelElement {Text = "Aantal records : " + RowCount, Margin = margin, Font = new Font(_btnStandaardSortering.Font.FontFamily, 10)};
                var stackpanel = new StackLayoutPanel {Orientation = Orientation.Horizontal, RightToLeft = true};
                stackpanel.Children.Add(_lblRecordCount);
                stackpanel.Children.Add(_btnExcel);
                stackpanel.Children.Add(_btnPdf);
                stackpanel.Children.Add(_btnAdd);
                stackpanel.Children.Add(_btnCollapse);
                stackpanel.Children.Add(_btnExpand);
                stackpanel.Children.Add(_btnStandaardSortering);
                var rel = new RadElement();
                rel.Alignment = ContentAlignment.TopRight;
                rel.Children.Add(stackpanel);
                GridViewElement.GroupPanelElement.Children.First().Children.First().Children.Add(rel);
                GridViewElement.GroupPanelElement.TextAlignment = ContentAlignment.MiddleLeft;

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3564 posts

    Posted 18 May 2017 Link to this post

    Hello Hans, 

    Thank you for writing.  

    Here is the modified code snippet applicable for the latest version:
    public class CustomGrid : RadGridView
        public override string ThemeClassName 
        {
            get
            {
                return typeof(RadGridView).FullName; 
            }
        }
     
        protected override RadGridViewElement CreateGridViewElement()
        {
            return new CustomRadGridViewElement();
        }
    }
     
    public class CustomRadGridViewElement : RadGridViewElement
    {
        protected override Type ThemeEffectiveType    
        {
            get   
            {
                return typeof(RadGridViewElement);    
            }
        }
     
        protected override GroupPanelElement CreateGroupPanelElement()
        {
            GroupPanelElement groupPanel = base.CreateGroupPanelElement();
     
            RadButtonElement exitButton = new RadButtonElement();
            exitButton.Text = "Exit";
            exitButton.MaxSize = new System.Drawing.Size(50, 20);
            exitButton.Click += exitButton_Click;
            exitButton.Alignment = ContentAlignment.TopRight;
            groupPanel.Children[1].Children.First().Children.Add(exitButton);   
             
            return groupPanel;
        }
     
        private void exitButton_Click(object sender, EventArgs e)
        {
            RadMessageBox.Show("Exit");
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top