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

Remove GridView GroupPanel close [x]

2 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 2
Daniel asked on 08 Nov 2014, 02:01 AM
     Hello, How can I remove the Close icon in GridView GroupPanel see attached image. I just want to use the sorting function of the group column or any work around to enable the user to sort the group.


thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Nov 2014, 02:43 PM
Hello Daniel,

Thank you for writing.

When you drag a certain column and drop it onto the GroupPanelElement, the grid data is grouped by this column. Each GroupFieldElement shows a close button by which you can remove the specific GroupDescriptor. Clicking over the GroupFieldElement changes the groups sort order (ascending or descending). Please refer to the attached SortGrouping.gif file. In order to hide the close button, you should subscribe to the GroupByChanged and set the RemoveButton.Visibility property to false for each GroupFieldElement:
private void radGridView1_GroupByChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
    if (this.radGridView1.GridViewElement.GroupPanelElement.PanelContainer.Children != null &&
        this.radGridView1.GridViewElement.GroupPanelElement.PanelContainer.Children.Count > 0)
    {
        TemplateGroupsElement templateGroupsElement = radGridView1.GridViewElement.GroupPanelElement.PanelContainer.Children[0] as TemplateGroupsElement;
        if (templateGroupsElement != null)
        {
            foreach (GroupElement groupElement in templateGroupsElement.GroupElements)
            {
                foreach (GroupFieldElement groupFieldsElement in groupElement.GroupingFieldElements)
                {
                    if (groupFieldsElement.RemoveButton.Visibility == ElementVisibility.Visible)
                    {
                        groupFieldsElement.RemoveButton.Visibility = ElementVisibility.Collapsed;
                    }
                }
            }
        }
    }
}

Note that in this case in order to remove the GroupDescriptor, you should drag the GroupFieldElement and drop it between the grid header cells. This behavior is demonstrated on the attached RemoveGrouping.gif file.

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
Daniel
Top achievements
Rank 2
answered on 13 Nov 2014, 07:13 AM
Thank you very much Desislava. This is very helpful.
Tags
GridView
Asked by
Daniel
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Daniel
Top achievements
Rank 2
Share this question
or