function fnCalculateColumnWidths

function fnCalculateColumnWidths

jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
edited September 2011 in DataTables 1.8
Hi

i think i found a small bug in function fnCalculateColumnWidths.
instead of:
[code]
/* Convert any user input sizes into pixel sizes */
for ( i=0 ; i

Replies

  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    also changed function fnScrollingWidthAdjust

    [code]
    if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY !== "" )
    {
    /* When y-scrolling only, we want to remove the width of the scroll bar so the table
    * + scroll bar will fit into the area avaialble.
    */
    var iOrigWidth = $(n).width();
    n.style.width = _fnStringToCss( $(n).outerWidth()-oSettings.oScroll.iBarWidth );
    }
    else if ( oSettings.oScroll.sX !== "" )
    {
    /* When x-scrolling both ways, fix the table at it's current size, without adjusting */
    n.style.width = _fnStringToCss( $(n).outerWidth() );
    }
    [/code]

    to:
    [code]
    if (oSettings.oScroll.sY !== "")
    {
    if (oSettings.oScroll.sX === "")
    {
    /* When y-scrolling only, we want to remove the width of the scroll bar so the table
    * + scroll bar will fit into the area avaialble.
    */
    var iOrigWidth = $(n).width();
    n.style.width = _fnStringToCss($(n).outerWidth() - oSettings.oScroll.iBarWidth);
    }
    else if (oSettings.oScroll.sX !== "")
    {
    /* When x-scrolling both ways, fix the table at it's current size, without adjusting */
    n.style.width = _fnStringToCss($(n).outerWidth());
    }
    }
    [/code]

    I think this was the original ideia with the width calculations when not using sY.
  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    still with the resize issue :)

    In function fnCalculateColumnWidths i add this bit of code, this way the width of the table is also calculated when the browsers window is resized to a smaller size than before and also it wasn't being resized when using sX or sY parameters.

    [code]
    /* When scrolling (X or Y) we want to set the width of the table as appropriate. However,
    * when not scrolling leave the table width as it is. This results in slightly different,
    * but I think correct behaviour
    */
    if (oSettings.oScroll.sX !== "" && oSettings.oScroll.sXInner !== "")
    {
    nCalcTmp.style.width = _fnStringToCss(oSettings.oScroll.sXInner);
    }
    if ( oSettings.oScroll.sX !== "" )
    {
    nCalcTmp.style.width = "";
    if ( $(nCalcTmp).width() < nWrapper.offsetWidth )
    {
    nCalcTmp.style.width = _fnStringToCss( nWrapper.offsetWidth );
    }
    }
    else if ( oSettings.oScroll.sY !== "" )
    {
    nCalcTmp.style.width = _fnStringToCss( nWrapper.offsetWidth );
    }
    [/code]

    to:
    [code]
    /* When scrolling (X or Y) we want to set the width of the table as appropriate. However,
    * when not scrolling leave the table width as it is. This results in slightly different,
    * but I think correct behaviour
    */
    if (oSettings.oScroll.sX !== "" && oSettings.oScroll.sXInner !== "")
    {
    nCalcTmp.style.width = _fnStringToCss(oSettings.oScroll.sXInner);
    }
    else
    {
    nCalcTmp.style.width = _fnStringToCss(nWrapper.offsetWidth);
    }

    var wWidth = $(window).width();
    if ($(nCalcTmp).width() > wWidth)
    {
    nCalcTmp.style.width = _fnStringToCss(wWidth);
    }
    [/code]

    Allan, if possible could you check if everything is correct in what i say (that way i can rewrite to is former state)

    Thks in advance,
    Joao Paulo Noronha
This discussion has been closed.