copyHtml5 and newline

copyHtml5 and newline

trongarttrongart Posts: 222Questions: 51Answers: 0
edited June 2022 in Free community support

In the description for copyHtml5, it is possible to replace \n in newline with any other character which puts the copied text together instead of in separate lines. However, this works only when newline is not empty so that the character is between the copied results.

How can I remove newline separators alltogether so that the copied data is combined in one row with no line breaks? Setting newline: '' does not work.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    I think you are running afoul of this line and it's falsy evaluation. The expectation was that there would always be a character present for a new line replacement, even if it is just a space, since otherwise you would run the risk of running words together - e.g. the\nnew would become thenew.

    You'll also need to set the stripNewlines for the exportOptions property to false since it is default enabled if you want custom control for new lines.

    stripNewlines should mean that you get no new lines in an exported row. If that isn't happening for you, can you link to a test case showing the issue please?

    Allan

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    @allan Thank you so much for looking into this. Here is a test case for my issue: live.datatables.net/jerixice/1/edit

    The goal is to click on the COPY button and to run all words together including the title and rows. I added stripNewlines: false, but it did not change anything.

    Instead of

    TITLE

    36
    66
    41
    18
    61
    38
    21
    46
    22
    36

    The copied text should be:

    TITLE36664118613821462236

  • rf1234rf1234 Posts: 3,000Questions: 87Answers: 421
    edited June 2022 Answer ✓

    stripNewlines should mean that you get no new lines in an exported row.

    In your code "36" represents one row, and "66" another. That means that "stripNewlines" is pretty much irrelevant for you.

    What you need is "customize":
    http://live.datatables.net/tavatete/1/edit

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    This is exactly what I was looking for! Thank you!

Sign In or Register to comment.