888Washington Posted November 8, 2017 Report Share Posted November 8, 2017 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! Quote Link to comment Share on other sites More sharing options...
cheonsa Posted February 5, 2019 Report Share Posted February 5, 2019 Hi @888Washington, I found a similar post about hiding columns if empty. You may check this for reference: Hope this helps. Regards, kristina Quote Link to comment Share on other sites More sharing options...
Aether Posted March 12, 2019 Report Share Posted March 12, 2019 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~ Quote Link to comment Share on other sites More sharing options...
Aether Posted March 12, 2019 Report Share Posted March 12, 2019 And you can also refer to this article if you want the code to hide a column per condition: Quote Link to comment Share on other sites More sharing options...
GoodBoy Posted January 1, 2022 Report Share Posted January 1, 2022 Hi! Sharing this another way to hide a column in a tabular report using CSS. Quote Link to comment Share on other sites More sharing options...
GoodBoy Posted January 1, 2022 Report Share Posted January 1, 2022 Sharing this solution as well with different case. Quote Link to comment Share on other sites More sharing options...
Kurumi Posted March 5, 2022 Report Share Posted March 5, 2022 Hi - Just to add, if you want to hide a column in a Pivot Report - you can use this code: Quote Link to comment Share on other sites More sharing options...
Kurumi Posted October 22, 2022 Report Share Posted October 22, 2022 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.