Jump to content
  • 0

Dynamically Change Column CSS Styling in a Pivot Table



Is it possible to dynamically change the styling of a column or header of a column in a pivot table.  I looked at this article but I don't see an opportunity to insert HTML Blocks or Calculation Fields in Pivot Tables.


In this screenshot, I want to pass in an external parameter called "Visit_Number".  So if Visit_Number=4 then I want the column or at least the header of the column highlighted.  Is this possible?

CH Pivot Table.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You cannot do this through Standard Feature. You need JavaScript if you want it dynamic.



<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

   if([@Virtual1] == 1){
document.querySelector("[class^='cbResultSetTableHeader'] th:nth-child(1)").style.backgroundColor = "red";

 if([@Virtual1] == 2){
document.querySelector("[class^='cbResultSetTableHeader'] th:nth-child(2)").style.backgroundColor = "yellow";


Virtual1 is my Parameter Name

You need to find the class of the tr first, so you can get the th child of that. You may use F12











Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...