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

Disabling / Hiding the grouped button in the Group Panel

3 Answers 363 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Andrews
Top achievements
Rank 1
Chris Andrews asked on 24 Sep 2011, 01:44 AM
Hello,

I have a grid view which I want to ALWAYS group by a particular column.  I need to let the user also group by more columns if they choose so I still need to show the group panel.

I can set the initial group descriptor fine in XAML, but would like to hide the button which appears in the Group Panel so the user cannot remove the grouping. (not sure what the proper term for this button is)

I found code to handle the Grouping event and canceling the removal, but I'd really like to have that button hidden if possible.

Thanks,
Chris

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 26 Sep 2011, 07:42 AM
Hello Chris,

 


Most probably you have used the code from the following forum thread "How to: Lock Grouping Column ?".
When you group column headers a GridViewGroupPanelCell appeared within RadGridView's GridViewGroupPanel. When the grouping is performed just find this button check its Content and set its Visibility to Collapsed:


private void RadGridView_Grouping(object sender, Telerik.Windows.Controls.GridViewGroupingEventArgs e)
{
    if (e.Action == GroupingEventAction.Remove &&
 ((e.GroupDescriptor as ColumnGroupDescriptor).Column as GridViewDataColumn).DataMemberBinding.Path.Path == "Property1")
    {
 
        e.Cancel = true;
 
    }
}
 
private void radGridView_Grouped(object sender, GridViewGroupedEventArgs e)
{
    if (this.radGridView.IsGrouping)
    {
 
        this.Dispatcher.BeginInvoke(new Action(()=>
        {
        GridViewGroupPanelCell button = radGridView.ChildrenOfType<GridViewGroupPanelCell>().Where(c => c.Content.ToString().Equals("Property1")).FirstOrDefault();
        button.Visibility = Visibility.Collapsed;
        }), System.Windows.Threading.DispatcherPriority.Render);
    }
}



Feel free to modify it in the way you need.

Greetings,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Chris Andrews
Top achievements
Rank 1
answered on 26 Sep 2011, 05:42 PM
Thank you Vanya, this code did exactly what I needed.

Although I can live with it, is there any way to change the "Grouped by: >" text back to look as if nothing is grouped.  (ie. "Drag a column header and drop...)

Once the user drags a new column, it will then show the "Grouped by: >" text.
0
Muhammad
Top achievements
Rank 1
answered on 01 Aug 2013, 02:52 PM
Hi,
   I am working on Telerik Grid View. I am trying to change the gridview grouping behaviour on runtime. from my viewmodel instead of code behind file. Actually with code behind I do have one option to clear GroupDescriptors from the grid. But is there any property or any workaround for ungrouping the a grid from ViewModel. I have tried to set the group panel visibililty and also tried setting column isGroupable property but it does not work. Any suggestions in this respect will be appreciated.

Saqib.
Tags
GridView
Asked by
Chris Andrews
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Chris Andrews
Top achievements
Rank 1
Muhammad
Top achievements
Rank 1
Share this question
or