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

Hiding Columns

Hello,

Do you provide any built-in functionality for removing grid columns? Something like the filter functionality but there are checkboxes with the column names next to them.


3 Replies

VN Vignesh Natarajan Syncfusion Team July 1, 2019 11:38 AM UTC

Hi Ivan,  

Thanks for contacting Syncfusion forums. 

Query: “Do you provide any built-in functionality for removing grid columns? Something like the filter functionality but there are checkboxes with the column names next to them. 

Yes. We have in built support to show / hide columns using a check box. Using ColumnChooser feature you can hide the visible column / show the hidden column and the column chooser is rendered within the Grid toolbar. Refer the below code example and screenshot to enable the column chooser in Grid. 

<EjsGrid id="Grid" AllowPaging="true" ShowColumnChooser="true" toolbar="@(new List<string>() { "ColumnChooser" })"> 
    <EjsDataManager Url="https://ej2services.syncfusion.com/production/web-services/api/Orders" Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager> 
    <GridColumns> 
        <GridColumn Field="OrderID" HeaderText="Order ID" ISPrimaryKey="true" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right" Width="90"></GridColumn> 
        <GridColumn Field="CustomerID" HeaderText="First Name" Width="90"></GridColumn> 
        <GridColumn Field="EmployeeID" HeaderText="Employee ID" Width="90"></GridColumn> 
        <GridColumn Field="Freight" HeaderText="Freight" Width="90"></GridColumn> 
    </GridColumns> 
</EjsGrid> 

 

Note: Uncheck the check boxes of the corresponding column name and click the OK button, it will hide those columns.  

For your convenience we have prepared a sample which can be downloaded from below  


Please get back to us if you have further queries.   

Regards,
Vignesh Natarajan. 



VO Volker September 12, 2022 10:59 AM UTC

Sorry, I don't know how to achive this:

How can we hide e.g. column "OrderID" on very first load, but allow to be displayed via ShowColumnChooser , when a user wants that later on?

By setting visible=false we cannot show it later any more, it remains hidden forever, no matter whether one switches this column to ON in the ShowColumnChooser :

<GridColumn Field="OrderID" HeaderText="Order ID" Visible="false">GridColumn>



NP Naveen Palanivel Syncfusion Team September 13, 2022 11:12 PM UTC

Hi Volker


Greetings from Syncfusion support.


We checked your query and we suspect when grid is render particular column set as visible is false later based on user , it could be showed on columnchoser . we prepared sample as per the requirement and attached in this ticket .

Please refer the attached sample for your reference .


Please get back to us if you need further assistance



Regards,

Naveen Palanivel


Attachment: Grid_e2fe4f97.zip

Loader.
Live Chat Icon For mobile
Up arrow icon