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

Is there a way i can hide columns?

Good morning, I'm using the pivot table as a component to visualize dynamic data. In my case, sometimes a certain column value dependes from another column value. A option to not render / show columns would be ideal, I searched the documentation but didn't found anything, is this supported?

I can't simply use values from my dataSource since there will be grouped values at certain rows, that's why hide/show columns would be ideal.

In the picture i attached, the second value column and style depends on the first value column, but the first one should not be visible.


Attachment: pivot_hide_column_2e46ed43.zip

4 Replies

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team February 27, 2023 10:23 AM UTC

Hi Jean,


You can hide specific columns in the pivot table based on your needs by using the columnRender event. Please refer the below code example.


Code example:

this.gridSettings = {

      columnRender: this.observable.subscribe((argsColumnRenderEventArgs=> {

        for (var i = 1i < args.stackedColumns.lengthi++) {

            if (args.stackedColumns[i].headerText == 'Units Sold') {

              // Hide the "Units Sold" here.

              (args.stackedColumns[ias any).visible = false;

            } 

          }

      }) as any,

    } as GridSettings;


Meanwhile, we have prepared a sample for your reference.


Sample: https://stackblitz.com/edit/angular-hfcvq9-gbnqxz?file=src%2Fapp.component.ts


Output screenshot:

Before:

After:


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.



JS Jean Sanson February 27, 2023 12:19 PM UTC

Hello Angelin, thank you for the suggestion. I'm currently using version 19.1.63 of the pivot view, in this version the interface for the columnRender function doesn't have the stackedColumns   property. I've tried, before creating this thread, to set the visible property to false on the columnRender.columns, but the result desired was not achieved. Is there a way I can achieve the result in this verison?




AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team February 28, 2023 08:45 AM UTC

Hi Jean,


The support for “stackedColumns” property in columnRender event is available from version 19.4.38. Therefore, we recommend that you upgrade the Syncfusion packages to the most recent version in order to use the "stackedColumns" property at your end.


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba


Loader.
Live Chat Icon For mobile
Up arrow icon