Jump to content
  • 0

Dynamically Change Column CSS Styling in a Pivot Table


CTW2020

Question

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.

https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/how-to-dynamically-change-the-background-of-a-results-page/

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.

 

Quote

<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";
}

});
</script>

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

image.thumb.png.045f570f59d257e154aa70668892547c.png

 

 

image.png.7af573419228f01f6cc2745e9b3d9e42.png

 

image.thumb.png.5d63871697c1f5c9b51961505b638cb4.png

image.png.911d466e3b63224e24ed0789051b5ba4.png

 

image.thumb.png.a5b89aa90774156ab854bde50b1dc490.png

 

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.

Guest
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.

Loading...
×
×
  • Create New...