DataTables logo DataTables

via Ad Packs
function fnCalculateColumnWidths
  • Hi

    i think i found a small bug in function fnCalculateColumnWidths.
    instead of:
    			/* Convert any user input sizes into pixel sizes */
    			for ( i=0 ; i<iColums ; i++ )
    			{
    				if ( oSettings.aoColumns[i].bVisible )
    				{
    					iVisibleColumns++;
    					
    					if ( oSettings.aoColumns[i].sWidth !== null )
    					{
    						iTmpWidth = _fnConvertToWidth( oSettings.aoColumns[i].sWidthOrig, 
    							oSettings.nTable.parentNode );
    						if ( iTmpWidth !== null )
    						{
    							oSettings.aoColumns[i].sWidth = _fnStringToCss( iTmpWidth );
    						}
    							
    						iUserInputs++;
    					}
    				}
    			}
    

    should be:
    			/* Convert any user input sizes into pixel sizes */
    			for ( i=0 ; i<iColums ; i++ )
    			{
    				if ( oSettings.aoColumns[i].bVisible )
    				{
    					iVisibleColumns++;
    					
    					if ( oSettings.aoColumns[i].sWidthOrig!== null )
    					{
    						iTmpWidth = _fnConvertToWidth( oSettings.aoColumns[i].sWidthOrig, 
    							oSettings.nTable.parentNode );
    						if ( iTmpWidth !== null )
    						{
    							oSettings.aoColumns[i].sWidth = _fnStringToCss( iTmpWidth );
    					                	iUserInputs++;
    						}
    					}
    				}
    			}
    

    or else iVisibleColumns is allways equal to iUserInputs, and iUserInputs will not reflect the value of how many sized columns there are by the developer.

    If i'm wrong for this line of thought i hope you find in your hearth some forgiveness for me :)
    just trying to make perfect what allready is excellent.
  • also changed function fnScrollingWidthAdjust

    			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() );
    			}
    

    to:
                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());
                    }
                }
    

    I think this was the original ideia with the width calculations when not using sY.
  • 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.

                    /* 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 );
    	}
    

    to:
                    /* 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);
                    }
    

    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.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion