cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Question:
In pivot tables, we would like to show column grand totals on top of the table and row grand totals at front. Please let us know how to alter positions.
Asnwer:
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);
 }

});
The below should work with Pivot 2.0. 
widget.on('ready', function(sender, ev){

//Define Variables
var lastRowClass = $('tr.table-grid__row:contains(Grand Total)',element).last().attr('class')
var firstClass = lastRowClass.split(' ')[0]
var secondClass = lastRowClass.split(' ')[1]
var firstRowClassBase = $('div.' + firstClass).first().attr('class').split(' ')[0]
var firstRowClassNumber = $('div.' + firstClass).first().attr('class').split(' ')[1].match(/\d+/g)

//If the first row class number does NOT equal zero...
if(firstRowClassNumber[0] != 0){

$('div.' + firstRowClassBase + ' div.table-grid__cell').css({'border-top':'','font-weight':''})
$('tr.' + firstClass).first().insertAfter($('tr.table-grid__row-' + (firstRowClassNumber - 1)))
$('div.' + firstClass).first().insertAfter($('div.table-grid__row-' + (firstRowClassNumber - 1)))
}

//Move Grand Total row to top
$('div.' + secondClass).insertBefore($('div.' + firstClass).first())
$('tr.' + secondClass).insertBefore($('tr.' + firstClass).first())
$('div.' + secondClass + ' div.table-grid__cell').css({'border-bottom':'1px solid #ccc','border-top':'1px','font-weight':'bold'})
$('tr.' + secondClass + ' td').css({'border-bottom':'1px solid #ccc','border-top':'1px','font-weight':'bold'})

});
Rate this article:
Comments
stockcer
7 - Data Storage
7 - Data Storage

This is not working for me.  Does someone have a more current suggestion.  I am using version L2023.9.0.214

Version history
Last update:
‎03-02-2023 08:36 AM
Updated by:
Contributors