Autohide columns when null values

Hi - Is there a property to make a column invisible, i a Grid, when all data in model is null?
Or must toggle the Visible="" in a custom method?



1 Reply

RS Renjith Singh Rajendran Syncfusion Team March 12, 2020 07:25 AM UTC

Hi Soren, 

Thanks for contacting Syncfusion support. 

We suggest you to bind a property for the GridColumn’s Visible property. And modify the value for the property to dynamically hide or show the Grid column based on your requirement. Please use the code below, 

 
<EjsButton @onclick="onclick">Hide Cols</EjsButton> 
 
<GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Customer Name" Visible="ShipCountryVisible" Width="150"></GridColumn> 
 
@code{ 
    public List<Order> Orders { get; set; } 
    public bool ShipCountryVisible = true;                //Initially the value is true, and the column will be displayed. 
    public void onclick() 
    { 
        ShipCountryVisible = false;    //Dynamically change the visibility for the ShipCountry column when button is clicked. 
    } 
    ... 
} 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon