Datatable re-sizes itself after filter and unfilter when using bCollapse (fix attached)

Datatable re-sizes itself after filter and unfilter when using bCollapse (fix attached)

jmooradijmooradi Posts: 1Questions: 0Answers: 0
edited June 2012 in Bug reports
This is a pretty minor bug it just causes scrollbar padding to right of the table be added to a table after filtering that wasn't added originally. This bug does not seem to occur in chrome, but does occur in the latest firefox, haven't tested any other browsers.

the main problem is starting at line 3151 in _fnScrollDraw:

[code]
// If scroll collapse is enabled, when we put the headers back into the body for sizing, we
// will end up forcing the scrollbar to appear, making our measurements wrong for when we
// then hide it (end of this function), so add the header height to the body scroller.
if ( o.oScroll.bCollapse && o.oScroll.sY !== "" )
{
nScrollBody.style.height = (nScrollBody.offsetHeight + o.nTHead.offsetHeight)+"px";
}
[/code]

This code may create an unnecessary scrollbar because its using the filtered table height even thought the table is not being filtered anymore.

I fixed the issue by moving this section starting at 3319 in _fnScrollDraw above the previous code at line 3151.

[code]
if ( o.oScroll.sY === "" )
{
/* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
* the scrollbar height from the visible display, rather than adding it on. We need to
* set the height in order to sort this. Don't want to do it in any other browsers.
*/
if ( ie67 )
{
nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+o.oScroll.iBarWidth );
}
}

if ( o.oScroll.sY !== "" && o.oScroll.bCollapse )
{
nScrollBody.style.height = _fnStringToCss( o.oScroll.sY );

var iExtra = (o.oScroll.sX !== "" && o.nTable.offsetWidth > nScrollBody.offsetWidth) ?
o.oScroll.iBarWidth : 0;
if ( o.nTable.offsetHeight < nScrollBody.offsetHeight )
{
nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+iExtra );
}
}
[/code]

this way the collapsed table height will be calculated before redoing the header calculations.

Thanks for a great jquery plugin! :)

Replies

  • bartmanbartman Posts: 5Questions: 0Answers: 0
    Thanks J!!

    Exactly the fix I needed as well.
This discussion has been closed.