Jump to content

How to hide empty columns in table report


Recommended Posts

  • 4 weeks later...
  • 1 year later...
  • 2 years later...
  • 3 months later...

Hi @Sheik

Yes, this can be achieved using JavaScript.

On your DataPage, go to Configure Results Page Fields. Add a Header and Footer, and the following on the Footer:
 

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


var  claimnumbers = document.querySelectorAll("table tr td:nth-child(1)");

var numOfEmpty = 0;
[].forEach.call(claimnumbers, function(elem, i) {

if(elem.innerHTML != "&nbsp;"){
numOfEmpty = 1;
}

});

if(numOfEmpty != 1){
var header = document.querySelector("table tr th:nth-child(1)");

var cells = document.querySelectorAll("table tr td:nth-child(1)");

header.style.display = "none";

[].forEach.call(cells, function(cell, i) {

cell.style.display = "none";

});

}

});
</script>

 

Wherein the 1 the "nth-child" occurences refer to the column to look out for. Change this value according to which order the column you need to apply this to come in.

Sample DP: https://c1hch576.caspio.com/dp/db26a0005d70567a6b3c43dab5cf where Account Number 4356 has  records with no claim numbers, so Claim Number column gets hidden

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
Reply to this topic...

×   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...
 Share

×
×
  • Create New...