Bug in fnAddData

Bug in fnAddData

gameshintsgameshints Posts: 1Questions: 0Answers: 0
edited January 2012 in Bug reports
I think I found a bug in fnAddData.

I was adding an single row, but the first value in the array was null.

When it did the [code] if ( typeof mData[0] == "object" ) [/code] check, it saw that [quote] typeof null == "object" [/quote] and thought my data was an array of arrays and added an entire new row for each column.

I'd propose the check be changed to [code] if ( typeof mData[0] == "object" && mData[0] != null ) [/code]

Thoughts?

Thanks,
Erik W

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Hi Erik,

    Good call - thanks for letting me know about this. I've just committed a small change to the 1.9 development version, which you can now download as the nightly from the downloads page: http://datatables.net/download .

    Rather than adding a check for null, I've used jQuery's $.isArray() method. I think this is probably more robust longer term, and slightly less code in DataTables :-)

    Allan
This discussion has been closed.