With 1.7 upgrade all table data turned to strings.

With 1.7 upgrade all table data turned to strings.

buckettbuckett Posts: 1Questions: 0Answers: 0
edited August 2010 in Bug reports
I was previously using DataTables 1.6 and getting data by specifying a sAjaxSource and a fnServerData to process the returned results. I was then building the data for the table and passing it to the callback. However I wasn't just putting strings into my table, but objects and integers. I would then define a fnRender for the columns containing objects which would turn the objects into string to be displayed in the table.

With the upgrade to 1.7 all data that the fnRender on the column gets are strings so I have to convert integers back and the objects are lost.

Is this a bug in 1.7 or was I abusing the datatables API in 1.6?

Replies

  • allanallan Posts: 57,300Questions: 1Answers: 9,127 Site admin
    Hi buckett,

    I'm afraid that this is sort of intentional in 1.7. DataTables will 'normalise' any input data to be a string in 1.7, since non-string data could cause a number of problems for the sorting functions and various plug-ins which expected the data to be a string. What isn't intentional, of course, is that it's broken your application! Indeed, I've been wary about make any changes to the input data (null changed to an empty string for example) but this seemed like the best thing to do to try a simplify data handling.

    So one option is to simply use parseInt / parseFloat etc to get it back to being a number when you use it in fnRender - another might be to clone the array before passing a copy to DataTables to do whatever it wants with it.

    It's an interesting issue this - thanks for bringing it up. It's a decision that I'll watch closely and keep under review.

    Regards,
    Allan
This discussion has been closed.