We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to turn grouping on/off via code

Thread ID:





150051 Dec 18,2019 05:24 PM UTC Dec 19,2019 10:27 AM UTC Blazor 1
Tags: Grid
Scott Peal
Asked On December 18, 2019 05:27 PM UTC

I am using this code with an external menu item to hide/show the grouping feature of the grid. The grid does not refresh to hide the grouping box at the top of the grid. I also tried the RefreshHeader() with the same result. 

GridResults.AllowGrouping = !GridResults.AllowGrouping;

Note, VS gives an warning that this property should not be set outside the component. 

I also have this same issue with this command: GridResults.PrintMode = PrintMode.AllPages;
In with print, I have two menu items; "Print this page", and "Print all pages". So need to also set these via code behind.

Thanks for the help!

Renjith Singh Rajendran [Syncfusion]
Replied On December 19, 2019 10:27 AM UTC

Hi Scott, 

Thanks for contacting Syncfusion support. 

We suggest you to bind variables for these properties “AllowGrouping” and “PrintMode”, and modify those variables dynamically based on your requirement. We have prepared a sample to dynamically update these properties in a button click, please download the sample form the below link, 
Please refer the code below, 

<EjsGrid TValue="Order" ... AllowGrouping="@SetGroup" Toolbar="@(new List<string>() { "Print" })" PrintMode="@ChangeMode"> 
@code { 
   public bool SetGroup; 
    public PrintMode ChangeMode; 
    public void EnableGroup() 
        SetGroup = true; 
    public void DisableGroup() 
        SetGroup = false; 
    public void AllPrint() 
        ChangeMode = PrintMode.AllPages; 
    public void CurrentPrint() 
        ChangeMode = PrintMode.CurrentPage; 

Please get back to us if you need further assistance. 

Renjith Singh Rajendran. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon