Type Conversion

Type Conversion

mspanglermspangler Posts: 2Questions: 0Answers: 0
edited October 2010 in Bug reports
I upgraded from v1.6.2 to v1.7.3 and noticed that the data I was getting back from the server wasn't being converted to the appropriate type. For example I'm using the 'fnRowCallback' function to process every row and lets say aData[2] is a boolean value of 'true'. v1.6.2 reads aData[2].constructor as Boolean while v1.7.3 reads the constructor as a String. This might have been done on purpose but seems it should convert the object to the appropriate type.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi mspangler,

    This was indeed done on purpose - there were a couple of reasons for doing this:

    1. The data that is to be displayed will end up as a string when shown in the table, so it is expected that string (or some other display format like it, i.e. a number) would be given
    2. It makes sorting / filtering etc much easier and faster when dealing with only strings

    Having said that, I 110% agree that this is not a perfect situation! The type conversion happens after fnRender, so if you are modifying the data for display there, you'll get your original data type - but when it comes to the display callback functions like fnRowCallback, the conversion will already have happened.

    What I plan to do in future is to provide a method to attach data to a row, which will not be touched by DataTables. This meta data can then be used for rendering or whatever (for example a row ID is a common one).

    Allan
This discussion has been closed.