Hide a column - Linux Pivot

Sometimes we would like to hide a column in our pivot table so we will be able to apply a specific logic or order the table by a column without displaying it.
The following script will allow you to hide the needed columns in your Pivot table.
To implement it, please make sure to:
  1. Adjust the number of columns according to your widget
  2. Place 0 for the column you'd like to hide
  3. Save the script
  4. Refresh the page
The following script is adjusted for a pivot table with 5 columns, hiding 2 of them:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var newWidth = {
0: 100,
1: 0,
2: 100,
3: 0,
4: 100
}
var columnsToRemove = []
var passed = -1
var wasExecuted = false
widget.on('processresult', function(widget, args){
if (!wasExecuted) {
args.result.metadata.forEach(function(e, index) {
e.panel
if (e.panel != "scope" ) {
index = Object.keys(newWidth).length - index+passed;
if ( typeof(newWidth[index]) !== "undefined" ) {
e["format"] = {"width":newWidth[index]};
}
if (e.format.width === 0) {
columnsToRemove.push(index)
}
}
else {
passed ++
}
})
wasExecuted = true
}
})
widget.on('ready', function() {
columnsToRemove.forEach(function(item) {
var selector = "[class*=table-grid__cell--col-" + item +"]";
$(selector, element).each(function(i, lmnt) {
$(lmnt).text('')
})
})
})
Here is an example of the above script:
Before:
mceclip1.png
After: