Knowledge Base Article

Right Align Numeric Dimensions In Pivot And Table Widgets

Introduction
when adding numeric dimension to pivot and table widgets in the rows section and not the value section (in cases where the numeric value is an attribute and not a measure) you can change the alignment of the number dimensions to the left using the below script:
 

BEFORE

AFTER

 Script
add this code to the widget's script:
widget.on('ready', function(sender, ev){
$('td[fidx=1]',element).css('text-align','left'); /// / Column 1
$('td[fidx=2]',element).css('text-align','left'); // Column 2
$('td[fidx=3]',element).css('text-align','left'); // Column 3
$('td[fidx=4]',element).css('text-align','right'); // Column 4
$('td[fidx=5]',element).css('text-align','left'); // Column 5
$('td[fidx=6]',element).css('text-align','left'); // Column 6
$('td[fidx=7]',element).css('text-align','left'); // Column 7
$('td[fidx=8]',element).css('text-align','left'); // Column 8
$('td[fidx=9]',element).css('text-align','left'); // Column 9
$('td[fidx=10]',element).css('text-align','left'); // Column 10
$('td[fidx=11]',element).css('text-align','left'); // Column 11
$('td[fidx=12]',element).css('text-align','left'); // Column 12
});
Updated 03-02-2023

1 Comment

  • years ago there was a script posted to automatically right align number columns so users could add, remove, hide, and rearrange their table widget and still get numbers to right align.  But that script seems to have stopped working with upgrades

    This is what I found.  How do we get something that works with tables and piot tables?

    /* Right Align numbers in the table */
    
    widget.on('domready', function (a, b) {
                _.each ($('td', element), function (td) {
                            var $td = $(td);
                            if (!isNaN(parseFloat($td.text()))) {
                                        $td.css({ 'text-align': 'right' });
                            }
                });
    });