Renderer for data with long text and special char like « return »

Renderer for data with long text and special char like « return »

MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2

Link to test case: https://live.datatables.net/yevemire/5/edit
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hi,

In the data coming from an app, there are really long text with special characters (like return or maybe invalid ones I don't know) but I need to display theses texts. At least, replace the returns by br and maybe « clean » the text just in case.

In my original table, I'm using orthogonal data but I've made an example with one long text (see the line Tiger Nixon).
I don't want to show the column with the text, only when the user click on the line (responsive details)
As you can see, with this « large » texts, the table is not user friendly anymore...

https://live.datatables.net/yevemire/5/edit

I've tried to use texts renderers but I'm missing something I guess.

Thanks for your help

This question has accepted answers - jump to:

Answers

  • MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2

    This is an example « in real life », the table is inside a « fancybox». So when you're displaying a line, it's not super fancy anymore :)

    Table before displaying a line :

    and after :

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,944
    Answer ✓

    Your regex expression with replace() s not correct. It doesn't look like your data has \n so it won't match \r\n. Also you will need to escape the backslash so it is used as a literal character, for example: \\r. Updated example:
    https://live.datatables.net/yevemire/6/edit

    I added and commented out another option using replaceAll with a string.

    Kevin

  • MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2

    Thanks Kevin

    It works great on the live example, but I can't make it work with the real data.

    Sometimes, there is also \n like in this case :

    "Commentaire": "XXX toujours aussi discret et peu loquace répond à mes questions par des questions.\r\n\r\nIl est client XXX et se plaint du niveau de marge toujours plus bataillé par ses confrères.\r\n\r\nA mesure de la conversation il me questionne sur XXX et XXX.\r\n\r\nNous arrivons à la conclusion que je passerai le voir courant juillet pour faire un tour d'horizon des nouveautés, évolutions technologiques, échantillons autant sur XXX que pour XXX.\r\n\r\nil se dit finalement en réflexion pour remplacer son XXXX.\r\n",
    

    I will check if I can change the data before, maybe it will be easier

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,944
    Answer ✓

    I would add a second regex replace() the removes all \n.

    Kevin

  • MelodyNelsonMelodyNelson Posts: 213Questions: 33Answers: 2
    edited February 28

    Thanks again Kevin.

    My brain is soooo bad with regex. I changed the datasource (easier) and created a renderer with a p, now it looks better (I had to blur the content)

Sign In or Register to comment.