Page 1 of 1

CR/LF not visible in TextArea List View

Posted: Wed Apr 14, 2021 6:07 pm
by abmd82

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 <br>" seems to have no effect and I read in manual, that this does only work for memo fields.
What am I missing?


Re: CR/LF not visible in TextArea List View but when inline editing

Posted: Wed Apr 14, 2021 8:25 pm
by arbei

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);

Re: CR/LF not visible in TextArea List View (v2020)

Posted: Fri Apr 16, 2021 7:32 pm
by abmd82

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.


Re: CR/LF not visible in TextArea List View (v2020)

Posted: Fri Apr 16, 2021 8:09 pm
by abmd82

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)"


Re: CR/LF not visible in TextArea List View (v2020)

Posted: Sat Apr 17, 2021 10:37 am
by arbei

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 <br>" and use Row_Rendered server event to truncate, e.g.

$this->MyField->ViewValue = TruncateMemo($this->MyField->ViewValue, 2000);

Re: CR/LF not visible in TextArea List View

Posted: Tue Jan 31, 2023 6:03 pm
by philmills

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>";

Re: CR/LF not visible in TextArea List View

Posted: Tue Jan 31, 2023 9:25 pm
by philmills

How can i get dompdf to obey CR/LF ?
according to this css white-space: pre-line should work, but it doesn't:
https://github.com/dompdf/dompdf/issues/1814

any ideas?


Re: CR/LF not visible in TextArea List View

Posted: Tue Jan 31, 2023 9:34 pm
by arbei

PDF is exported by ExportPdf class, you should customize the class (see viewtopic.php?t=50364) or the ewpdf.css.


Re: CR/LF not visible in TextArea List View

Posted: Wed Feb 01, 2023 5:56 pm
by philmills

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 ?


Re: CR/LF not visible in TextArea List View

Posted: Wed Feb 01, 2023 7:14 pm
by arbei

You may copy the original dompdf extension and customize it as your own. Also read Making Extensions.


Re: CR/LF not visible in TextArea List View

Posted: Wed Feb 01, 2023 8:03 pm
by philmills

Can I redefine like this in user styles?

.ew-export-table td {
  border: 1px solid;
  border-color: #DEE2E6;
}