fnAddTr plugin hidden fields calculation bug

fnAddTr plugin hidden fields calculation bug

3nacria3nacria Posts: 2Questions: 0Answers: 0
edited January 2014 in Bug reports
In my table I use the this plugin to put table rows, one by one.
My table starts with some hidden columns, if the user wants to change the initial configuration, I use the fnSetColumnVis function to show or hide the columns.
Doing this operation I notice that the code shows some wrong columns.

I find that in the code of fnAddTr plugin, when the it searches the hidden tds, makes some mistakes:

// Hidding invisible columns
for ( var i = (aInvisible.length - 1) ; i >= 0 ; i-- )
oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]];
nTr.removeChild( nTds[aInvisible[i]] );

I think it's not correct to put nTds[aInvisible[i]] inside _anHidden[ i ] as in the code:

[code] oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]]; [/code]

but for me the correct way is:

[code] oSettings.aoData[iIndex]._anHidden[ aInvisible[i] ] = nTds[aInvisible[i]]; [/code]

aInvisible[] is the the array of indexes of td that can be hidden, so aInvisible[i] contains the correct index, while i is only the index for the cycle.


  • allanallan Posts: 55,882Questions: 1Answers: 8,835 Site admin
    Thanks for posting this.

    DataTables 1.10's new `row.add()` method has built in support for adding TR nodes, so this plug-in is soon to be redundant :-)

  • 3nacria3nacria Posts: 2Questions: 0Answers: 0
    Thanks for your answer.

    Errata corrige: i called "fnAddTr" as Plugin but actually i would have to call API Method: fnAddTr.

This discussion has been closed.