fnUpdate bug in 1.9.4?

fnUpdate bug in 1.9.4?

jeffrojeffro Posts: 1Questions: 0Answers: 0
edited October 2012 in Bug reports
Hello, I've noticed that fnUpdate( [row], pos, col) no longer works as expected when col == 1 (or any other number). The documentation says that col is ignored if the data passed in is an array, but what actually happens is that it puts the passed in array into the column. So when I do this:

fnUpdate([1, 2, 3, 4, 5], 1, 1)

I get something like

[1, [1, 2, 3, 4, 5], 3, 4, 5]

instead of

[1, 2, 3, 4, 5]

The code comments say

oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], 1, 0 ); // Row

But the code itself does the following check

if ( $.isArray(mData) && iColumn === undefined )

So it appears that the docs and comments are incorrect and that col must be undefined for the array case to work.

Replies

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    > The documentation says that col is ignored if the data passed in is an array

    I'm sorry to say that the documentation is actually wrong here - I'm working on a fix. Because of the newer abilities of 1.9.x a single array can be the value of a single cell, so automatically assuming an array is for the whole row is incorrect. You need to pass in 'null' for the column if you are to target the whole row.

    Allan
  • w1tebearw1tebear Posts: 1Questions: 0Answers: 0
    Hi! I have found a similar problem with this same area of code - the docs for fnUpdate, parameter 3 say:

    {int}: The column to update (set to null or undefined to update the whole row)

    In actuality, the code explicitly checks for undefined - specifying a null causes an error and the fnUpdate fails (I am passing an object as my first parameter - on looking at the code it appears that the same would apply if I passed an array).

    Simply modifying the documentation to specify undefined only (not null) would fix this problem.

    Thanks!
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Oops - thanks for that! Fixed now.

    This will all be must simpler with the 1.10 API (when it is done!).

    Allan
This discussion has been closed.