Renderer for data with long text and special char like « return »
Renderer for data with long text and special char like « return »
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
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 :
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
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 :
I will check if I can change the data before, maybe it will be easier
I would add a second regex replace() the removes all \n.
Kevin
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)