Incorrect table width in hidden containers
Incorrect table width in hidden containers
krojew
Posts: 30Questions: 0Answers: 0
Hi,
When a table with hidden columns is constructed in a hidden container, it's width is computed incorreclty. You can see it by inserting a table in a initially hidden jQuery UI tab: http://img513.imageshack.us/img513/2822/plasmadesktopxq1890.png
Using fnAdjustColumnSizing() doesn't solve the problem.
When a table with hidden columns is constructed in a hidden container, it's width is computed incorreclty. You can see it by inserting a table in a initially hidden jQuery UI tab: http://img513.imageshack.us/img513/2822/plasmadesktopxq1890.png
Using fnAdjustColumnSizing() doesn't solve the problem.
This discussion has been closed.
Replies
Two things spring to mind - firstly are you calling fnAdjustColumnSizing whenthe table is made visible, and do you have a CSS declaration something like table { width: 100% }?
Allan
I'm calling fnAdjustColumnSizing() every time a tab is selected and the table becomes visible. I also have width: 100% in my CSS for the table. I've noticed the same thing happens when opening a jQuery UI dialog with a table with hidden columns.
Allan
I've copied a fragment of my website with the table: http://kl-software.com/tabletest.php - you can see the problem after switching the tab.
[code]
$('#new-table').css('width', '100%').dataTable().fnAdjustColumnSizing();
[/code]
it should do the trick for now. I'll have a look into why this is happening - but that work around will hopefully do what you need :-)
Regards,
Allan
[code]
$('#tabs').tabs({
selected: 0,
select: function() {
alert('setting css');
setTimeout( function () {
$('#new-table').css('width', '100%');
newTable.fnAdjustColumnSizing();
}, 10 );
}
});
[/code]
Unless the tabs script has an callback for when the tab is made visible, which would be better.
Allan
Good to hear that does the job!
Allan
Allan
Allan
I found an easy way to reproduce this bug:
1. Make your browser window small.
2. Open a page containing a table with initially hidden columns. I don't know if it's important, but I've tested the table inside initally visible jQuery UI tab.
3. Maximize browser window.
Result - the table keeps previous width. This does not happen without hidden columns. Setting css('width', '100%') on every $(window).resize() event helps.
I have a similar problem with ie 8: i have tabs with details rows in all tabs ,
a error apear after a click in details and navigation in tabs .
if i comment $(table).dataTable().fnAdjustColumnSizing(); the problem will be resolved but the table column will not have correct width for all tabs.
Sorry about my bad english
hi!
For tabs solution is
$( "#tabs" ).tabs({
});