Simple Style format on a pivot column
I am trying to format a column of a pivot table, but are not being able to change it. I am using this in my script.
widget.on('ready', function(w, args) {
$('div', $('td.p-value, element)).css('text-align', 'center');
});td
Can somebody help.
-
Hi Eduardo,
You should be able to target a column via this code:
widget.on('ready', function(se, ev){
var columnIndex = 4; //The index of the column to change (starting with 0)
for (i = 0; i < $('tbody')[0].rows.length; i++) {
$($('tbody')[0].rows[i].cells[columnIndex]).css({
'text-align': 'center'
});
}
}); -
also take a look at this post, just change the alignment to center
-
Hi All,
Thank you for the replies, perhaps in the image it is not clear, but I also want to make bold the column at the far right and I have not been able to do so. Also, the code provided only centers the numbers and not the text, with this line I am able to center all the text, but the column on the far right which is a value column in the pivot table. The first 4 columns are rows.
//this works for everything except the far right column
widget.on('ready', function(w, args) {
$('div', $('td.p-dim-member', element)).css('text-align', 'center');
}); -
Ronen,
Thank yout this almost achieves what I want, my last issue is that when I centered the right column, the format was applied to the whole column and I dont want the column title to be centered.
widget.on('ready', function(w, args) {
$('div', $('td.p-dim-member', element)).css('text-align', 'center');
$('td[fidx=4]',element).css('text-align','center');
$('td[fidx=4]',element).css({'font-weight':'bold'})
});
Please sign in to leave a comment.
Comments
5 comments