JS to hide Pivot Column

Comments

5 comments

  • Avatar
    Donald Lui

    Hi Pavle,

     

    You can simply press the on/off button to turn off or on data you are trying to display. It will still retain the record for aggregation but it will not display the specific column

    hope this helped

    Donald

    0
    Comment actions Permalink
  • Avatar
    Pavle Puac

    Hi Donald,

    thanks for the reply! Unfortunately, it is slightly more complex than that. I got a script from Sisense support, so posting it here in case you, or anyone else, need it in future.

    widget.on('ready', function(se, ev){ 
     var columnIndex = 2;

     columnIndex = columnIndex.toString();
     var containers = [
      $('.p-container table tr td.p-measure-head, .p-container table tr td.p-dim-member-head, .p-container table tr td.p-total-head, .p-container table tr td.p-grand-total-head'),
      $('.p-container table tr td.p-value'), 
      $('.p-container table tr td.p-value:not(.p-first-data-col)')
     ]
     for (k = 0; k<containers.length; k++) {
      hideColumns(containers[k], columnIndex);    
     };

     function hideColumns(container, columnIndex) {
      var title = $(container);
          if (!$(container)) {
        return;
          };
          for (i = 0; i<title.length; i++) {
        if ($(title)[i].attributes.fidx.value === columnIndex) {
            debugger;
            $($(title)[i]).remove()
        }
          }
     }
    });

    Thanks!

    Pavle

    0
    Comment actions Permalink
  • Avatar
    Anjali Yadav

    Hi there

    Any suggestions on how to modify the script above to hide the first Pivot ROW ?

    Thanks

    An

    0
    Comment actions Permalink
  • Avatar
    Jessica Orlando

    Any way to do this to hide the first value on Rows instead of columns? I also have an Order column on my Rows that I would like hidden.

     

    Thanks!

    0
    Comment actions Permalink
  • Avatar
    Tri Anthony Situmorang

    Anjali and Jessica, this script should remove the first row in a pivot:

     

    widget.on("ready", function(w, args){

    $("tbody tr:first-child", element).remove();

    });

    0
    Comment actions Permalink

Please sign in to leave a comment.