Strip html doesnt replace non breaking space.

Strip html doesnt replace non breaking space.

park896park896 Posts: 6Questions: 2Answers: 0

When exporting to csv, excel, pdf, etc if stripHtml is true, the resulting output should replace ' ' with ' '.

This question has accepted answers - jump to:

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Im not sure about that, I would think it just removes the tag itself.

    However, if the content being exported has a \n or \r\n after the <br>, then I would think setting stripNewlines: false in the exportOptions setting for csv would take care of this, it uses the buttons.exportData(), which according to the reference guide..

    stripNewlines - Indicate if newline characters should be stripped from the read data if there are any (true) or not (false).
    Default - true.

    So by default, all new lines are being stripped

  • park896park896 Posts: 6Questions: 2Answers: 0

    Sorry, the formatting stripped out what was between the quotes. The data in my table cell contains a non breaking space &.n.b.s.p. I have stripHtml = true and stripNewlines = true, but the non breaking space is still exported to csv, excel, pdf, etc. The problem is that those applications do not display the content correctly. I would be ok with any solution including passing a format callback function or something like that so that i could format the text myself. Ideally the library would handle it for me, but I understand it cant feasible handle every scenario under the sun. I would prefer not to have to create my own copy of the exportData code and recreate the wheel when the built-in buttons are so close to working for me.

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    Answer ✓

    Oh, I see, I thought it was a <br> you were specifying, hah, sorry.

    Well if you're just looking to parse the data when you export it, I had to do something similar to that recently, heres my thread about it.

    The only difference was I ended up using the content altering for both the table display and exporting, if you want it to alter the data just while it exports it, you're going to have to take advantage of the orthogonal setting within the buttons.exportData().

    Heres the exact quote you're looking for from the thread I linked above:

    If you want to custom format the text for the exported data, you need to use the orthogonal option of the buttons.exportData() method (which you can set using the exportOptions option for the button you are working with (e.g. excelHtml5).

    That uses DataTables' orthogonal data abilities - so you would need to define a columns.render option for the column you want to customise the data export for, and give it a function that will handle the orthogonal data you want to export.

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    Answer ✓

    I was kinda hoping I could define a custom orthogonal data type, then filter on that, but no dice.

    Attempt: http://live.datatables.net/xoxiraxu/1/edit?js,output

  • park896park896 Posts: 6Questions: 2Answers: 0

    That was exactly what i wanted. I got your sample working using this
    http://live.datatables.net/xoxiraxu/2/edit?js,output
    you just have to specify the orthogonal property inside an exportOptions property to get it working.

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Oh, hahahha, i thought i did, i forgot to throw it inside the exportOptions, oops, glad you saw that

This discussion has been closed.