Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Need to hide an entire column of a table
aesfandi
I need to hide all rows of a specific column in a table and
tried the following:
1. Added "mytable" bookmark to the table.
Added a Hide icon grid above the table and entered:
"javascript:var table=document.getElementById('mytable');table.style.display='none';void(0)";
for its Self URI Hyperlink.
When I click the Hide icon, it hides the entire report - all columns and rows.
2. Added "col2" bookmark to the data for column2 of the table.
Changed the URI to use 'col2' instead of 'mytable'.
When I click the Hide icon, it hides only the very first row of the column2. rest of
column2 rows are still visible.
3. Added "col2_lab" to the label for column2 of the table.
Changed the URI to use 'col2_lab' instead of 'col2'.
When I click the Hide icon, it hides the column2 label and all of its rows but with
a catch - rows are not completely hidden - they are shrunk to a very small width but
still visible.
4. Came across the following solution:
<script>
function hidecolumn(cind){
var table=document.getElementById("mytable");
var myrows = table.getElementsByTagName('tr');
for (var row=1; row<myrows.length;row++) {
var cols = myrows[row].getElementsByTagName('td');
cols[(cind)].style.display='none';
}
}
</script>
which I added as a text palette and added the function call
hidecolumn(2) to the URI. But, clicking the Hide icon does not
do anything. By the way, the script code above also appear in
the preview.
Any suggestions?
Find more posts tagged with
Comments
averma
Hi aesfandi,
2. When you add a bookmark to a report element, it uses that for its HTML id in the final output. In this case the final output contained serveral div tags with the same id and your code only finds the first one and hides it and that explains why you see the rest of the rows.
3. You would also need to find the container cell of each data/label and hide it as well to completely hide it.
Ashwini
johnw
You have two options.
1) Use a server side solution.
2) Use a client side/Javascript solution.
I will focus on 1, since for 2 you will need to set identifiable bookmarks and use Javascript to find all cells for each column and hide.
What you can do for server side hiding is something similar to what I did in this article:
http://digiassn.blogspot.com/2007/05/birt-strong-suit-is-in-realm-of-online.html
Instead of adding a sort condition to a table, you will be using a visibility expression on each column, and returning the HIDE as true if the report parameter to hide that column contains the column ID.
It will require a re-render of the report each time, but it will work.
John