With the YUI datatable control you can render a HTML table into a new table with enhanced features such as column hiding. To hide and show columns the CSS style is changed to display:none. One particular problem with hidden columns is, that not the cell itself gets hidden but the div inside the cell. I am guessing that the style display:none is attached to the div inside the cell and not the cell itself because it would render the method showColumn() useless if you use the datatables cellClickEvent.
Maybe you have seen the post JavaScript: Hide and show columns of a YUI dataTable using checkboxes and noticed the ugly border on hidden columns:

This is what Firebug outputs after inspecting the element:

As you can see there is a div inside the cell that actually is hidden, not the cell itself. And here is the CSS class for the table cell:
.yui-skin-sam .yui-dt td {datatable.css (line 7)
border-color:-moz-use-text-color #CBCBCB -moz-use-text-color -moz-use-text-color;
border-style:none solid none none;
border-width:medium 1px medium medium;
margin:0;
padding:0;
text-align:left;
}
Notice the border-style:none solid none none part? Try setting it to border-style:none none none none and you will see that the border is not shown anymore. But this will just mess up the table on the positions of the cells compared to the table head part.
So what I needed is to modify the CSS classes so that the table cells of the table and the table head cells will be hidden when the class yui-dt-hidden is applied to it. This is what the table looks like after fixing the CSS classes.

And this is what Firebug displays:

Clearly to see that not only the div inside the cell is hidden by applying style display:none but as well as the table cell itself. Keep in mind that when you have attached the datatables method showColumn() to the cellClickEvent, its complete useless now. Since you can not click in any cell anymore to show the column.
To use this CSS fix I recommend to put these lines into your own CSS file and include this after the YUI CSS files for the datatable.
th.yui-dt-hidden,
tr.yui-dt-odd .yui-dt-hidden,
tr.yui-dt-even .yui-dt-hidden {
display:none;
}
This makes sure that the entire table cells of the table head and the table body will be hidden by applying the yui-dt-hidden style.




#1 by Luke Smith on June 5th, 2009
Quote
The “bug” you are fixing is by design. Your fix is unnecessary as DataTable already supports what you are trying to accomplish using a different API method: removeColumn.
There are three ways to hide columns in DataTable:
1) hideColumn collapses a column (leaving the border there on purpose)
2) removeColumn removes all trace of the column from the UI
3) omitting the column definition in the DataTable configuration from the get go will skip that column during rendering
None of these options affect the data that are stored in the DataTable’s RecordSet. The data that populates the RecordSet is defined in the DataSource’s fields collection. Whether or not you include a column in the display is up to you, but you will always have access to all field data in all records.
Have a look at this example for reference: http://yuiblog.com/sandbox/yui/v270/examples/datatable/hidden_cols.html
As you see here, only one column is displayed, but all three data columns are accessible to the DataTable.
The same applies for removeColumn. The provided column is removed from the display, but the data persists in the DataTable’s RecordSet collection.
http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_removeColumn
and
http://developer.yahoo.com/yui/datatable/#colapis
Hope this clarifies things,
Luke
#2 by Norman on June 5th, 2009
Quote
Hello Luke,
thank you for your comment.You are right, I already guessed in this post http://normankosmal.com/wordpress/?p=44 that there is a reason for this.
I should have put the “bug” bit in quotes. The one purpose I can think of to not hide the complete table cell is that it would render the cellClickEvent useless.
When using the removeColumn() and insertColumn() methods one needs to write slightly more code. You need a way to store the removed columns from the table so that you are able to insert them back at a later point on certain events because insertColumn() expects a column object as argument. Maybe there is another way to get the removed column back into the table but I did not find anything in the API.
Norman
#3 by Luke Smith on June 16th, 2009
Quote
TBH, I agree that hideColumn and showColumn should leave no hint, or perhaps accept a boolean arg to trigger hinting, but that’s the component author’s prerogative. I just help out with DT/DS sometimes :)
I wasn’t around when that decision was made, so it could be that there was public outcry for hinting. I’ve never seen a real life use case, but I haven’t exactly been looking for one.
It’s certainly worth filing an enhancement request if one doesn’t exist already. The more feedback the better.
#4 by Arpit Jain on November 20th, 2009
Quote
Hi Norman,
Thanks a lot for posting solution for this, it helped a lot..!
#5 by Xavier Lluch on December 23rd, 2009
Quote
Thanks a lot!
I was crazy trying to find a solution for this bug… i didn’t known if i was doing something wrong. I had tried to solve by javascript but your solution is simpliest and better. It is quite ugly to show hidden column borders like original YUI table shows.
Thanks a lot from Catalonia for your efford, your clarity in your exposition and the simplest solution you provide us!
#6 by admin on December 23rd, 2009
Quote
Hello Xavier,
thanks for your comment, glad this helped you. But as Luke already pointed out, this behaviour is intended. I never really could figure out why they are leaving the border visible but since it is intended I`d rather call this a workaround instead of a bugfix ;)
Regards,
Norman
#7 by Pandiya Chendur on September 3rd, 2010
Quote
th.yui-dt-hidden, tr.yui-dt-odd .yui-dt-hidden, tr.yui-dt-even .yui-dt-hidden { display:none; }I used the above code to fix hidden column border issue.. It works perfectly in firefox and google chrome but not in IE. See my screenshot,
http://img32.imageshack.us/img32/7058/datapw.jpg
#8 by hugues on September 24th, 2010
Quote
Hello,
I have better results with
th.yui-dt-hidden,td.yui-dt-hidden,
tr.yui-dt-odd .yui-dt-hidden,
tr.yui-dt-even .yui-dt-hidden {
display:inherit;
}
Otherwise I have somme trouble with the description bar od the table and horizontal scrolling
#9 by admin on September 24th, 2010
Quote
Thanks for sharing that hugues!
#10 by Ajay Kakkar on March 1st, 2011
Quote
Thanks a lot, It resolved my problem too.
#11 by halfmoon0220 on June 6th, 2013
Quote
I used removeColumn() first, but it causes the browser too slowly.
Thanks for this method, it works well. But when I use ScrollingDataTable to enable the scrolling xy-axes, the problem comes. When I drag the x-scrolling to the right, the head of table and the data in the body is not aligned. How can I fix it?