Table too wide
Table too wide
Despite bAutoWidth, the (competey dinamically generated) table ends with a style "margin-left: 0pt; width: 100%;" I don't understand where it comes from.
This obviously changes the width of every column. I ended up doing:
[code]
$("table.display").css("margin", "auto");
$("table.display").css("width", "0");
width_px = $("#hands").width() + "px";
$("div.fg-toolbar").css("margin", "auto");
$("div.fg-toolbar").css("width", width_px);
$("div.display").find("thead").css("margin", "auto");
$("div.display").find("thead").css("width", width_px);
[/code] at the end of fnDrawCallback() as a workaround, would prefer to fix it in the original place, if I can find it, any idea?
This obviously changes the width of every column. I ended up doing:
[code]
$("table.display").css("margin", "auto");
$("table.display").css("width", "0");
width_px = $("#hands").width() + "px";
$("div.fg-toolbar").css("margin", "auto");
$("div.fg-toolbar").css("width", width_px);
$("div.display").find("thead").css("margin", "auto");
$("div.display").find("thead").css("width", width_px);
[/code] at the end of fnDrawCallback() as a workaround, would prefer to fix it in the original place, if I can find it, any idea?
This discussion has been closed.
Replies
Allan
The initialization is:
"bPaginate": false,
"bProcessing": true,
"bJQueryUI": true,
// "bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": Math.round(0.7 * $(window).height()),
// "bServerSide": true,
"sAjaxSource": "hands.php",
11 rows, 9 visible, 2 hidden. they take 100% of the width of the screen even when
[code]
table.display {
margin; auto;
width; 0;
clear: both;
border-collapse: collapse;
}
[/code]
Someone is adding this fixed style, which takes precedence.
So a work around is to put a wrapper element around the table and use that to control the width. It's also a lot more actually in terms of pixels since tables can be influenced by a wide variety of parameters.
Regards,
Allan
With no width defined it takes 100% too.
And indeed scrolling is the responsible, when taken off table looks good.
It seems scrolling does not like autowidth, or gets confused by it.
Can you point to me where is this code in scrolling?
Thanks,
Gerardo
With no width defined it takes 100% too.
And indeed scrolling is the responsible, when taken off table looks good.
It seems scrolling does not like autowidth, or gets confused by it.
Can you point to me where is this code in scrolling?
Thanks,
Gerardo
[code]
/* No x scrolling */
o.nTable.style.width = "100%";
[/code]
in _fnScrollDraw. However, I would normally recommend that scrolling be used with auto width in order to get the column calculations correct. As I say - the width 100% on the table makes the column sizes a lot easier to work with. If you want to constrain the table, then the easiest way is to simply use div.dataTables_wrapper { width: whatever; } and then let the table inside that container do what it needs to do.
Allan
$("table.display").css("width", "0");
width_px = $("#hands").width() + "px";
$("table.display").css("width", "100%");
$("#hands_wrapper").css("margin", "auto");
$("#hands_wrapper").css("width", width_px);
[/code]
Almost perfect. SCroll bar is inside the table width, though, so a there is a small scroll X.
So width_px should be $("#hands").width() + SCROLL_BAR_WIDTH + "px".
Tried 12, works fine.
Table centered, auto width working, scroll bar working, next to the table, thead and tfoot centered too.
Only thing left is THs, they start at same place as the others but are much longer than the actual column content. From here, any redraw aligns it with the rest of the table, but globally, invividual THs have different widths and/or different placement and the related TD columns.
Thanks,
Gerardo
Allan
Thanks,
Gerardo.
Thanks,
Gerardo