Skip to content

Commit

Permalink
Fix #162 - Flexible width is width="100%" is applied as attribute to …
Browse files Browse the repository at this point in the history
…the HTML table

- Attach an event handler to the window to resize the table. Note that
  this isn't debounced - possibly it should be in future(?), but don't
  want to add the additional code required if it isn't required. It
  seems to function perfectly well for me!

- Unbind needs to unbind by the instance unique reference since there
  might be multiple tables listening for the event.
  • Loading branch information
Allan Jardine committed Mar 3, 2013
1 parent 25eaa86 commit b87187f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions media/src/api/api.methods.js
Expand Up @@ -494,6 +494,7 @@ this.fnDestroy = function ( bRemove )


/* Blitz all DT events */ /* Blitz all DT events */
$(oSettings.nTableWrapper).unbind('.DT').find('*').unbind('.DT'); $(oSettings.nTableWrapper).unbind('.DT').find('*').unbind('.DT');
$(window).unbind('.DT-'+oSettings.sInstance);


/* If there is an 'empty' indicator row, remove it */ /* If there is an 'empty' indicator row, remove it */
$('tbody>tr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove(); $('tbody>tr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove();
Expand Down
9 changes: 9 additions & 0 deletions media/src/core/core.sizing.js
Expand Up @@ -249,6 +249,15 @@ function _fnCalculateColumnWidths ( oSettings )
if ( widthAttr ) if ( widthAttr )
{ {
oSettings.nTable.style.width = _fnStringToCss( widthAttr ); oSettings.nTable.style.width = _fnStringToCss( widthAttr );

if ( ! oSettings._attachedResizing &&
(oSettings.oScroll.sY !== '' || oSettings.oScroll.sX !== '') )
{
$(window).bind('resize.DT-'+oSettings.sInstance, function () {
_fnScrollDraw( oSettings );
} );
oSettings._attachedResizing = true;
}
} }
} }


Expand Down

0 comments on commit b87187f

Please sign in to comment.