Return a number column as a string instead

Return a number column as a string instead

malletheadmallethead Posts: 3Questions: 1Answers: 0

Hi all,
Completely new to DataTables and primarily a ColdFusion developer so I hope I use relevant terminology in this question.

We use DataTables to show large grids of data. On one page we offer an export function. So once we have the result set from DataTables we use that variable to export the data for an Excel spreadsheet.

Because the accessory_number column can be ,"ABC12345", or ,1234567, - sometimes it is coming back from DataTables as a string and sometimes as a number. When we export the data to the Excel spreadsheet this causes data to be displayed aligned-left and some to be aligned-right.

How can I tell DataTables to ALWAYS return the accessory_number column as a string so that it will align-left in the spreadsheet export.
Thanks, Jerry

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @mallethead ,

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • malletheadmallethead Posts: 3Questions: 1Answers: 0

    Thank you Colin. I'm looking over the page you linked to. I should be able to drag a fix out this info.

  • malletheadmallethead Posts: 3Questions: 1Answers: 0

    Appending a \0 character at the beginning of the data fields where the typeof == 'number' upon export solved the problem. There does not appear to be any effect on sorting or observable difference in formatting because of the inclusion of this character.
    Jerry

This discussion has been closed.