Table width when redrawing
Table width when redrawing
Hi Allan
I now have a really great implementation of datatables which is doing nearly everything I need. One of the things it does is allow the user to add and remove columns dynamically. If the user selects a large number and gets a horizontal scrollbar that's fine. However, if they then remove columns the table stays the same width. I am calling fnDraw once done, here is the code. Can you let me know how to get the table to shrink to the correct width please?
[code]
var updateColumns = function ()
{
$('input.columnSelector[type=checkbox]').each(function (){
var iCol = findColumnNumber($(this).attr('id').substring(6, $(this).attr('id').length));
oTable.fnSetColumnVis( iCol, $(this).is(':checked'));
});
oTable.fnDraw();
}
[/code]
I now have a really great implementation of datatables which is doing nearly everything I need. One of the things it does is allow the user to add and remove columns dynamically. If the user selects a large number and gets a horizontal scrollbar that's fine. However, if they then remove columns the table stays the same width. I am calling fnDraw once done, here is the code. Can you let me know how to get the table to shrink to the correct width please?
[code]
var updateColumns = function ()
{
$('input.columnSelector[type=checkbox]').each(function (){
var iCol = findColumnNumber($(this).attr('id').substring(6, $(this).attr('id').length));
oTable.fnSetColumnVis( iCol, $(this).is(':checked'));
});
oTable.fnDraw();
}
[/code]
This discussion has been closed.
Replies
The only way to alter this at the moment is to shrink the size of the container I'm afraid - and I suspect that is easier said than done since you need to know how much to shrink it by, which would require a table clone with the current content and no sizing applied.
Column / table width is the bane of DataTables development! I can see why many other grid components choose to go with DIVs (although for me progressive enhancement wins every time :-) ).
Allan