Jump to content

Recommended Posts

Hi,

I'm trying to hide two columns in a tabular report if one of the fields has null values or is empty.  I've tried the following Java Script several different ways, but can't seem to get it to work correctly.  A submission form feeds this tabular report, and if the user doesn't enter values in the 'Qty' field, it should be hidden on the tabular report.

<script>
var stl='none';  
var tbl = document.getElementsByTagName('table')[0];
var rows = tbl.getElementsByTagName('tr');
var EmpQty = ("[@field:Employee_Productivity_Qty]").length;

if (EmpQty<0) {

for (var row=1; row<rows.length;row++)
{
var cels = rows[row].getElementsByTagName('td');
cels[7].style.display=stl;
cels[8].style.display=stl;
}
var heads= tbl.getElementsByTagName('th');
heads[7].style.display=stl;
heads[8].style.display=stl;
}
</script>

Thank you!

 

 

Screen Shot of Tabular Report.JPG

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Hi @888Washington,

You can also just try to use this code instead:

<script type="text/javascript">

var elems = document.querySelector(".cbResultSetTable tbody").children;
console.log(elems);

for (let i = 0; i < elems .length; i++) {
elems[i].children[07].style.display = "none";
elems[i].children[08].style.display = "none";
}

</script>

Just change the child number in this line "elems.children[07].style.display = "none";", first column is "0" and so on. 

Note: Add this code inside your Footer, make sure that you unchecked the "enable HTML Editor" in the advance option.

I hope this helps :) 

~WatashiwaJin~

Link to comment
Share on other sites

  • 2 years later...
  • 2 months later...
  • 7 months later...

Hi - Just an update, here are the other ways for you to hide column in the Tabular Report:

Without Download/Sort Options:

table[id*='cbTable'] > tbody > tr[class*='cbResultSetTableHeader'] > th:nth-child(1), td[class*='cbResultSetData']:nth-child(1){

    display:none !important;
  
}

With Download/Sort Options:

table[id*='FreezeTabularHeaderObj'] > tr[data-cb-name="header"] > th:nth-child(1), td[class*='cbResultSetData']:nth-child(1), #target table:nth-of-type(1) th:nth-of-type(1), #target table:nth-of-type(2) th:nth-of-type(1){

    display:none !important;
  
}

Replace 1 with the position order of column to be 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...
×
×
  • Create New...