diference of using node vs data

diference of using node vs data

arcanisgkarcanisgk Posts: 41Questions: 12Answers: 0

given a table cell contains the following:

Hello Word1,<br>Hello Word2

to get on browser view:

Hello Word1,
Hello Word2

when i try to use format for excel exportation:

format: {
    body: function (data, row, column, node) {
        data = $(node).clone('td');
        data = data.text();
        data = data.replace(/<br\s*\/?>/ig, "\r\n");
        return data;

this not replace my br with line brake to get work for excel esport... when i see that .text() result, i get Hello Word1,Hello Word2 whitout <br>.

why node or clone td; not copy the <br> to be replace in next interaction???


  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768
    edited October 2022

    My understanding is text() only returns text not the tags. Instead you proably will need to use html(). See this technote. This exmple, using your code, shows that node returns the node as it is in HTML with the br tag.

    You may also need to add the wrap text attribute. See this thread for an example.


  • arcanisgkarcanisgk Posts: 41Questions: 12Answers: 0

    the two questions are not related, they are different things... in this question I have already obtained the line break for excel but I cannot upload a test case, since the error is visible when the excel is opened and all cells with 2 or more lines with style 55; they apply a text wrap that allows the full text to be seen if I remove it or combine it with another style, excel stops respecting line breaks and even if they exist... I must go to each cell one by one, click on it as if I were going to edit the text remove the focus (no change made) from the cell so that it respects the line break again...

  • allanallan Posts: 61,686Questions: 1Answers: 10,100 Site admin

    I don't actually understand the question I'm sorry to say. Do you mean the height of the row in Excel is not correct to be able to see the whole text?


Sign In or Register to comment.