Space in fields.
Space in fields.
MickB
Posts: 103Questions: 25Answers: 2
Hi,
Our product codes have two spaces in:
eg WH MCL 1
When rendered in the Datatable I get WH MCL 1, so one of the spaces is dropped.
When I view the source, the two spaces are there.
Any idea where this is happening?
Mick
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Looks like two spaces to me.
What "source"? HTML? Database?
No, it is one space:
The HTML source which has two spaces:
Mick
Umm, spaces are compacted in HTML, how HTML is formatted and how it should be rendered are not connected. If you need to retain multiple spaces you'd need to write a datatables column renderer that either puts the value in pre tags or changes the spaces to no break spaces.
That unfortunately sounds like the correct answer.
In your column definition, add:
Per docs: https://datatables.net/reference/option/columns.render
Another option is use to the
white-space
CSS property. Set it topre
and your double spaces should be shown as expected.Allan