fnClearTable resets column head widths in 1.7.6
fnClearTable resets column head widths in 1.7.6
andyburke
Posts: 10Questions: 0Answers: 0
I'm calling fnClearTable() to clear a table before re-adding data to it. Doing so seems to reset the column header widths. The columns that contain the data still seem to be properly sized, it's only the headers that get screwed up. I am using bJQueryUI = true.
Any help would be appreciated.
Any help would be appreciated.
This discussion has been closed.
Replies
Scrolling code clones the TH row, and somehow uses only TD for width calculations.
Gerardo
So, the bug is apparently that fnClearTable() + bJQueryUI + scrolling = broken table header widths on redraw.
Is there a way I can fix this?
[code]
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": 200,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
} );
setTimeout( function () {
$('#example').dataTable().fnClearTable();
}, 2000);
} );
[/code]
The table is initially shown with a scrollbar, but then when the table is cleared, there is no scrollbar, so the columns are resized to take that into account. Another factor might be that the data you have in the table is forcing the column widths to be a certain size - when you then remove that data there is nothing to force the size other than the column titles, so it will use that information only.
Allan
1) take in account the (visible) TH width when calculating TD/(hidden) TH width (to take the max), so there is no column narrower than its header.
2) Use the hidden TH calculated width (which is the same as the TDs) and assign them to the visible TH.
Would this work?
Thanks,
Gerardo
Allan
I see. But the problem is those widths (visible TH row, data rows) do not match (in certain cases?)
Thanks,
Gerardo
Allan
But it has no effect on the visible TH when there is a scrollbar.
Scenario:
I resize the table with width 0.
This resizes data columns correctly, but does not take headers into account.
At least one column has a header wider than the current size of the column, that makes all headers widths slightly different than data counterparts.
Solved this by adding 30px to the min width above, now headers and data widths match.
Hth,
Gerardo
Any chance that column headers could be redrawn when we draw entries so they match up?
[code]
paragraphstable = $('#paragraphstable').dataTable( {
"bJQueryUI": true,
"sScrollY": "200px",
"bScrollCollapse": true,
"bPaginate": false,
"aoColumns": [ { "sType": "numeric" }, null,null,null,null,null ]
} );
ID
Paragraph Title
Paragraph Text
echo "
echo "" . $paragraph['id'] . "";
echo "" . $paragraph['title'] . "";
echo "" . $paragraph['text'] . "";
echo "copy";
echo "