There are text fields containing longer text with CR/LF. But they are no visible in list view. When I click on inline edit, the breaks become visible. But I need them in list view for readability.
The setting “Replace CR +LF by
” seems to have no effect and I read in manual, that this does only work for memo fields.
What am I missing?
If your field values use “\r” as line breaks, you may use Row_Rendered server event (see Server Events and Client Scripts in the help file), e.g.
$this->MyField->ViewValue = str_replace(["\\r\\n", "\\r"], "<br>", $this->MyField->ViewValue);
Okay, just created a complete new project with the exact same view. Guess what… your code works in this project. I think I have to make some comparisons between the projects to find the difference. Strange!Thank you for your help When I find out, what caused the error, I will post it here.
Found the problem: I limited the length of the field to 2000 chars. When this value is set, the function has no effect.Tried it for- and backward and it’s reproducible.View Tag → Format-> “Max length (List page)”
That is because the “Max length (List page)” option tries to show long data by a one-line short text like “Some long string…” in a table column in the List page, it will remove the white spaces first, but in your particular case you use a rather large number 2000 so you may still want line breaks. In such case you may disable “Max length (List page)”, enable “Replace CR +LF by
” and use Row_Rendered server event to truncate, e.g.
$this->MyField->ViewValue = TruncateMemo($this->MyField->ViewValue, 2000);
I found you can use CSS to force linebreaks to be obeyed using this in row_rendered
$this->MyField->ViewValue = "<span style='white-space: pre-wrap;'>".$this->MyField->CurrentValue."</span>";
How can i get dompdf to obey CR/LF ?
according to this css white-space: pre-line should work, but it doesn’t:
Issues · dompdf/dompdf · GitHub ideas?
PDF is exported by ExportPdf class, you should customize the class (see https://discourse.hkvstore.com/t/customizing-export-v2021/4020/1) or the ewpdf.css.
Adding white-space: pre-wrap; to .ew-table td in ew.pdf fixed it.
.ew-table td, .ew-table th {
padding: 3px;
border: 0.5px solid;
border-color: #DEE2E6;
white-space: pre-wrap;
}
Is there a way to set this in user styles, so it doesn’t get overwritten when generating files ?
You may copy the original dompdf extension and customize it as your own. Also read Making Extensions.
Can I redefine like this in user styles?
.ew-export-table td {
border: 1px solid;
border-color: #DEE2E6;
}