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:

[code]
......
// 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]] );
}
.....
[/code]

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.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 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 :-)

    Allan
  • 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.

    3n
This discussion has been closed.