Disabling / Hiding the grouped button in the Group Panel

4 posts, 0 answers
  1. Chris Andrews
    Chris Andrews avatar
    41 posts
    Member since:
    Mar 2010

    Posted 23 Sep 2011 Link to this post

    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
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 26 Sep 2011 Link to this post

    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 >>

  3. Chris Andrews
    Chris Andrews avatar
    41 posts
    Member since:
    Mar 2010

    Posted 26 Sep 2011 Link to this post

    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.
  4. Muhammad
    Muhammad avatar
    4 posts
    Member since:
    Jun 2013

    Posted 01 Aug 2013 Link to this post

    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.
Back to Top