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.
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((args: ColumnRenderEventArgs) => { for (var i = 1; i < args.stackedColumns.length; i++) { if (args.stackedColumns[i].headerText == 'Units Sold') { // Hide the "Units Sold" here. (args.stackedColumns[i] as 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.
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?
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