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

Extra buttons in GroupPanelElement

6 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Hans asked on 19 Nov 2014, 09:15 AM
Is it possible to add extra button to the GroupPanelElement of a radgridview?
See attached picture.
Hans Heuvelman

6 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Nov 2014, 02:19 PM
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.

 
0
Hans
Top achievements
Rank 1
answered on 28 Nov 2014, 08:10 AM
Most excellent. Thanks a lot.
For simplicity I added a StackLayoutPanel to the grouppanel, and by buttons to the StackLayoutPanel.
0
Hans
Top achievements
Rank 1
answered on 28 Nov 2014, 10:51 AM
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?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Dec 2014, 05:57 PM
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.

 
0
Hans
Top achievements
Rank 1
answered on 17 May 2017, 10:36 AM

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;

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 May 2017, 07:45 AM
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.
Tags
GridView
Asked by
Hans
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Hans
Top achievements
Rank 1
Share this question
or