- Home
- Forum
- JavaScript - EJ 2
- Hiding columns when there are multiple column dimensions
Hiding columns when there are multiple column dimensions
Earlier this year you posted a reply to a similar question. I've tried to use this example and have found it does work when there are only measures in columns.
Here's a sample pivot view and what I'd like to achieve. As you can see, there are measures and a dimension called 'scenarios' in the columns axis.
However, when the columns indicated are made invisible this is the result:
It's definitely close but, as the caption in the image shows, the 'den Employment Q2 Adult' and the
'num Employment Q2 Adult' headers are missing. These are not set to hide the column. Only the 'scenarios' members of the stackedColumns array are hidden.
It will be great if you are able to suggest what I'm doing wrong.
Thanks
Bill
Here's the code I'm using. It's a little more complex that in the example from earlier this year. That's because it's necessary to skip over most of the columns.
columnRender: function (args)
{
// Permitted columns are any with measures do not start with 'den' or 'num'
// if the column does start with den or num then only the Actual scenario is permitted
let measureColumnIndex = 0
let ignore = false;
args.stackedColumns.forEach( (column, index) =>
{
if ( index == 0 ) return;
if ( measureColumnIndex )
{
measureColumnIndex = 0;
if ( ignore || column.headerText == 'Actual' ) return;
column.visible = false;
// args.stackedColumns[measureColumnIndex].visible = false;
}
else
{
measureColumnIndex = index;
ignore = ! ( column.headerText.startsWith('den') || column.headerText.startsWith('num') );
}
} );
}
Hi Bill,
Using the columnRender event, you can hide specific columns in the pivot table. However, we are now experiencing a problem with OLAP pivot table while hiding certain columns, which we have considered as a bug "Hiding specific columns not working properly in OLAP Pivot Table". And the fix for this issue will be included in our July third weekly release which is scheduled to be rolled out on July 12, 2023. You can track the status with the feedback link below.
We appreciate your patience until then.
Regards,
Angelin Faith Sheeba
Hi Bill,
We are glad to announce that our weekly Release V22.1.38 is rolled out and the fix for the reported issue “Hiding specific columns not working properly in OLAP Pivot Table” has been included in this release. And please refer the below code example to hide the specific columns using columnRender event in the pivot table.
Code Example:
|
gridSettings: { columnRender: function (args) { for (var i = 1; i < args.stackedColumns.length; i++) { if ( args.stackedColumns[i].field == 'Accessories' && args.stackedColumns[i].columns && args.stackedColumns[i].columns[0].headerText == 'Customer Count' ) { // Hide the customer count value column under Accessories here. args.stackedColumns[i].columns[0].visible = false; } } }, }, |
Meanwhile, we have prepared a sample for your reference.
Sample: https://stackblitz.com/edit/popnng-ps4wwk?file=index.html,index.js
Output screenshot:
Please let us know if you have any concerns.
Regards,
Angelin Faith Sheeba
- 2 Replies
- 2 Participants
- Marked answer
-
BS Bill Seddon
- Jun 25, 2023 10:18 PM UTC
- Jul 12, 2023 06:10 AM UTC