What happens is that the DataTables sets the width of the CSS table when it is initialized with the calculated value - this value is in pixels, so it will not change when dragging and dropping. The reason for this is to stop the table and columns (the width of the columns is also set) by jumping in width when you change the pagination.
What you can do to stop this behavior in DataTables is to set the autoWidth parameter to false.
$('#example').dataTable( { "autoWidth": false } );
This will stop the DataTables by adding its estimated width to the table, leaving your (presumably) width: 100% alone and allowing you to resize. Adding relative width to the columns would also help stop the columns bouncing off.
Another option built into DataTables is to set the sScrollX parameter to enable scrolling, since DataTables will set the table to 100% the width of the scrollable container. But you may not need to scroll.
The prefect's solution would be if I could get the width of the CSS table (provided that it is applied, i.e. 100%), but without parsing the style sheets, I see no way to do this (i.e. basically want $ ( ). css ('width') to return the value from the stylesheet, not the calculated pixel value).
Allan Jardine Nov 26 '11 at 17:36 2011-11-26 17:36
source share