FixedHeader is broken for tables with colspans (1.10.10+)?

FixedHeader is broken for tables with colspans (1.10.10+)?

AlexBarAlexBar Posts: 4Questions: 1Answers: 0

I'm using 1.10.9 and have a table with fixed header enabled. My table has a few rowspans and it works just fine. Here is a live example http://live.datatables.net/quzasiye/1/watch?html,js,output

Recently I've updated to the latest datatables version and looks like fixed header functionality does not work anymore. Here is an example with version 1.10.10 (any later versions have the same issue) - http://live.datatables.net/quzasiye/2/watch?html,js,output

What this functionality removed? Was it broken unintentionally? Or should I do some additional configurations to make it working again?

Answers

  • AlexBarAlexBar Posts: 4Questions: 1Answers: 0
    edited October 2016

    I think I found an issue in datatable code. See function "_fnCreateTr":

    1.10.9:

    /* Process each column */
                for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
                {
                    oCol = oSettings.aoColumns[i];
        
                    nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
                    cells.push( nTd );
        
                    // Need to create the HTML if new, or if a rendering function is defined
                    if ( !nTrIn || oCol.mRender || oCol.mData !== i )
                    {
                        nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
                    }
    

    1.10.12

    /* Process each column */
                for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
                {
                    oCol = oSettings.aoColumns[i];
        
                    nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
                    nTd._DT_CellIndex = {
                        row: iRow,
                        column: i
                    };
                    
                    cells.push( nTd );
        
                    // Need to create the HTML if new, or if a rendering function is defined
                    if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
                         (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
                    ) {
                        nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
                    }
        
                    /* Add user defined class */
                    if ( oCol.sClass )
                    {
                        nTd.className += ' '+oCol.sClass;
                    }
    

    Code introduced in 1.10.10 breaks the logic with colspans.
    In case of colspan nTd is undefined and you get an error while trying to access nTd._DT_CellIndex.

    Can it be fixed in next version?

  • AlexBarAlexBar Posts: 4Questions: 1Answers: 0

    allan, what can you say about it?

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    colspan and rowspan have never worked properly in the tbody in DataTables. They are not supported there and probably never will be due to the complexity they introduce.

    Sorry I don't have better news. If it worked at all before then it was entirely by fluke (although I'm very surprised that it worked at all).

    Allan

  • AlexBarAlexBar Posts: 4Questions: 1Answers: 0

    Ah... I see.

    Actually I tried to add a check that nTr is not undefined before setting _DT_CellIndex and fixedHeader started working again. Ordering and searching feature is disabled for my table. If any chance to add that condition, it would be great because at least fixedHeader will be unofficially supported.
    Anyway, thanks for your reply, Allan.

This discussion has been closed.