mdupras Posted December 9, 2008 Report Share Posted December 9, 2008 Hi all -- I want to include an auto-incrementing ID in my search results because I want that to be the default sort order (especially to make a map mashup default to center on the first item in the table). But I don't want that field/column to display on the results page. Is there a way to hide it with JavaScript? Thanks! -- Mike Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted December 10, 2008 Report Share Posted December 10, 2008 Hi Mike, This feature is added to the new feature requests list for the future releases. For the time being a Java Script can be used to hide the column. You can contact Caspio Professional Service department to have the script written for your specific case. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
ycollier Posted December 25, 2008 Report Share Posted December 25, 2008 Hi Mike, Here is an example of script that you can use to hide or modify the result table. Put it in the footer : var stl='none'; // means hidden var tbl = document.getElementsByTagName('table')[5]; // 5 means there are 4 tables in the html page before the caspio table var rows = tbl.getElementsByTagName('tr'); for (var row=1; row { var cels = rows[row].getElementsByTagName('td'); cels[1].style.textAlign='center'; // aligns the second column cels[2].style.textAlign='right'; cels[2].style.fontWeight ='bold'; cels[3].style.textAlign='right'; if (cels[4].innerHTML >= 1.2) // check the value in the 5th columns and change it in red if higher than 1.2 {cels[4].style.color='red'} cels[6].innerHTML= Math.round(100*(cels[6].innerHTML-1))+'%'; // change the value in a percent based on a calculation if (cels[6].innerHTML=='0%') {cels[6].innerHTML=''} cels[6].style.textAlign='center'; cels[7].style.display=stl; // hide the 8th column } Hope this helps. Yves Quote Link to comment Share on other sites More sharing options...
mdupras Posted February 4, 2009 Author Report Share Posted February 4, 2009 Just saw this reply -- your code worked beautifully! I wanted to hide the first column, and this was all I needed: <script language="javascript" type="text/javascript"> var stl='none'; var tbl = document.getElementsByTagName('table')[0]; var rows = tbl.getElementsByTagName('tr'); for (var row=1; row<rows.length;row++) { var cels = rows[row].getElementsByTagName('td'); cels[0].style.display=stl; } </script>Thanks!-- Mike Quote Link to comment Share on other sites More sharing options...
scuriel Posted February 27, 2015 Report Share Posted February 27, 2015 I updated the code by mdupras for my table to also hide the header for the column. In the for loop I changed the var "row" to 0. Quote Link to comment Share on other sites More sharing options...
Ashfak Posted August 19, 2016 Report Share Posted August 19, 2016 On 2/5/2009 at 0:50 AM, mdupras said: Just saw this reply -- your code worked beautifully! I wanted to hide the first column, and this was all I needed: <script language="javascript" type="text/javascript"> var stl='none'; var tbl = document.getElementsByTagName('table')[0]; var rows = tbl.getElementsByTagName('tr'); for (var row=1; row<rows.length;row++) { var cels = rows[row].getElementsByTagName('td'); cels[0].style.display=stl; } </script> Thanks! -- Mike annabd16 1 Quote Link to comment Share on other sites More sharing options...
Ashfak Posted August 19, 2016 Report Share Posted August 19, 2016 To hide the header of the table following line can be added below the loop: var heads= tbl.getElementsByTagName('th'); heads[0].style.display=stl; Quote Link to comment Share on other sites More sharing options...
TMeyer Posted May 10, 2017 Report Share Posted May 10, 2017 Thanks for the above post. I have seen this solution in a few posts now. My problem is that my table has several 'pages' to it, and when I move to another page, the formatting does not carry over, so the columns become visible again. Any solutions for having this apply to all pages in the table when there are too many records to display all on one page? Quote Link to comment Share on other sites More sharing options...
Franchiser Posted August 22, 2017 Report Share Posted August 22, 2017 Try to use this code:<script language="javascript" type="text/javascript">var stl='none';var tbl = document.querySelectorAll('table[id^="cbTable"]')[0]; var rows = tbl.getElementsByTagName('tr');for (var row=1; row<rows.length;row++){var cels = rows[row].getElementsByTagName('td');cels[1].style.display=stl;}rows = tbl.getElementsByTagName('tr');for (var row=0; row<rows.length;row++){var cels = rows[row].getElementsByTagName('th');cels[1].style.display=stl;}</script> Please note that the index for column starts at zero(0). So, if you will applying this code you need to set the cels[] number properly of the column that you want to hide. Example: You have 3 columns and you want to hide the last column, the cels[] must be set like this: cels[2] Quote Link to comment Share on other sites More sharing options...
Kurumi Posted March 18, 2022 Report Share Posted March 18, 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...
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.