changing Grand Total Position

Answered

Comments

8 comments

  • Avatar
    Brian Bontrager

    Here's part of what you are looking for. This script will move the grand total row to the top.  


    widget.on('ready', function(sender, ev){

    if ($(".p-grand-total-row-head", element).length > 0)
    {
    setTimeout(function(){
    $('table#pivot_',element).prepend($('table#pivot_', element).find('tr:last'));
    $('div.table-container table', element).prepend($('div.table-container table', element).find('tr:last'));
    $('tbody',element).each(function(){
    $(this).find('tr:first td').not('.phantom').css('border-bottom', '1px solid #ccc').find($('span, .p-value')).css('font-weight', 'bold');
    });

    $('.p-grand-total-row-head.p-first-data-col').css('border-left', 'none');
    },500);
    }

    });

     

    1
    Comment actions Permalink
  • Avatar
    Elliott Herz

    Hey Sai,

    I built a script that moves 1 of the grand totals from the right so that it is the first column on the left. Not sure of how many grand totals you were trying to move to the front, but you can use this as an example:

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

    //move the right grand total header as the first field on the left
    var header = $('td.p-grand-total-head','[id="' + widget.oid+ '"]')[0];
    $(header).insertAfter($('tr#pivot__ACCRowArea')[0].children[0]);

    //find all the right grand total tags (specific to the fidx).
    var tags2 = $('[id="' + widget.oid+ '"]').find("[fidx=2]");
    var grandTotalTags = [];
    for(var i=0; i<tags2.length; i++) {
    if(tags2[i].className === 'p-value p-total-col-val' || tags2[i].className === 'p-value p-first-data-col p-total-col-val') {
    grandTotalTags.push(tags2[i]);
    }
    }
    var rows = $('td.p-dim-member','[id="' + widget.oid+ '"]');

    //move the right grand total before the other columns
    for(var i=0; i<rows.length; i++) {
    $(grandTotalTags[i]).insertAfter($(rows[i]));
    }

    //move right grand total for bottom grand total
    var bottom = $('td.p-grand-total-row-head','[id="' + widget.oid+ '"]')[0];
    var lastElement = bottom.parentElement.lastElementChild;
    $(lastElement).insertAfter($(bottom));

    });

    1
    Comment actions Permalink
  • Avatar
    Oxana Noa Umansky

    Thanks so much Brian and Elliot!

    @devops, let us know if you've achieved what you've been looking for!

     

    0
    Comment actions Permalink
  • Avatar
    Siva

    Hi Brian and Elliot,

    Thanks Brian and Elliot. I have implemented these scripts in widget. It is working fine. We will try to edit the script given Elliot to work in all the scenarios.

    We are using Sisense only by embedded JS in our application. So, we want to make sure that there will not be any performance impact after using the script.

    Regards,
    Sai Krishna.

    0
    Comment actions Permalink
  • Avatar
    Analytics & Insights

    Hi all! Hope you are going well.

    Does anyone knows how to do the same thing to the subtotal lines?

     

    Best,

    Camila.

    0
    Comment actions Permalink
  • Avatar
    Siva

    We have same required. Please post if someone has the solution.

    0
    Comment actions Permalink
  • Avatar
    Brandan Spears

    @Elliott Herz do you have a script for two Grand Total columns? 

    0
    Comment actions Permalink
  • Avatar
    Elliott Herz

    Hey Brandan, I don't have a script offhand that does it.

    0
    Comment actions Permalink

Please sign in to leave a comment.