Column width set to 133px in Chrome, even if it doesn't need to.
Column width set to 133px in Chrome, even if it doesn't need to.
Not sure what's causing this, whether it's FixedColumns, Datatables, or something of my own doing. For whatever reason, the column width in Chrome is set to 133px, even if the content could easily fit in a smaller width. It does stretch it to a larger size if needed, but it's almost like the minimum width is 133px. IE and Firefox both display correctly, though. I'd like it to just be the size of the largest amount of data. bAutoWidth is set to false.
EDIT: Ah, figured it out. It's because I have a searchable column input in the footer, so it's stretching to fit that. My workaround is to set the input boxes to 1px by default and a class of "search_box", and in the fnDrawCallback, I have the following code (any suggestions are certainly welcome):
[code]
$('.search_box').each(function(){
$(this).css('width', $(this).parent().css('width'));
});
[/code]
EDIT: Ah, figured it out. It's because I have a searchable column input in the footer, so it's stretching to fit that. My workaround is to set the input boxes to 1px by default and a class of "search_box", and in the fnDrawCallback, I have the following code (any suggestions are certainly welcome):
[code]
$('.search_box').each(function(){
$(this).css('width', $(this).parent().css('width'));
});
[/code]
This discussion has been closed.
Replies
Allan
Allan
This is in the fnFooterCallback:
[code]
"fnFooterCallback": function(){
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
if($.browser.chrome)
{
$('tfoot input').each(function(){
var width = parseInt($(this).parent().css('width')) - 4;
$(this).css('width', "50px");
});
setTimeout(redraw_footer, 1);
}
}
[/code]
I then have the redraw_footer function (I subtract 4 because I have borders that throw it off):
[code]
function redraw_footer()
{
$('tfoot input').each(function(){
var width = parseInt($(this).parent().css('width')) - 4;
$(this).css('width', width + "px");
});
}
[/code]
It seems to require setting the correct width from a setTimeout, even if the value is 1. Not sure why? Since Chrome seems to be the only one with the issue, I only do this workaround in Chrome.