Skip to content

Commit

Permalink
Fix: When calculating the string width for column sizes, we know that…
Browse files Browse the repository at this point in the history
… we are going to be using strings for the display - so cast as a string, which means that we can take the length of any primitive (particularly numbers).

Fix: The max string width calculation was including HTML, which is just plain wrong since the HTML will be hidden. This is still not perfect since "iiii" takes less space than "mmm" in the browser display, but addressing that would take some serious clocks cycles, and this is good enough for now.
  • Loading branch information
Allan Jardine committed May 12, 2011
1 parent dd0e402 commit fcc41bc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions media/js/jquery.dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -5685,8 +5685,9 @@

for ( var i=0 ; i<oSettings.aoData.length ; i++ )
{
var s = _fnGetCellData( oSettings, i, iCol, 'display' );
if ( typeof s == 'string' && s.length > iMax )
var s = _fnGetCellData( oSettings, i, iCol, 'display' )+"";
s = s.replace( /<.*?>/g, "" );
if ( s.length > iMax )
{
iMax = s.length;
iMaxIndex = i;
Expand Down

0 comments on commit fcc41bc

Please sign in to comment.