This is a migrated thread and some comments may be shown as answers.

Remove \r\n from string.

6 Answers 1001 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Ezra
Top achievements
Rank 1
Ezra asked on 12 Nov 2020, 09:49 PM

Hello,

    In a report that I am working on I have a string field coming in from a web service data source that has carriage returns and line feeds in it.

    I would like to remove those \r\n instances and have a single line for my string field.

 

6 Answers, 1 is accepted

Sort by
0
Ezra
Top achievements
Rank 1
answered on 12 Nov 2020, 09:51 PM

Terribly sorry, didn't mean to post then.

For example: 

    data comes in as :

       "Test Field: answer

       Another Test Field: another answer"

 

     but I would rather have it formatted as :

        "Test Field: answer Another Test Field: another answer"

 

Is there a way to format my text this way?

0
Neli
Telerik team
answered on 17 Nov 2020, 01:34 PM

Hi Ezra,

You can try to concatenate the strings. For example:

= "Test field: " + Fields.[Test Field] + " Another test field: " + Fields.[Another Test Field] 

Please, check the attached report for further reference and let me know if that's the desired outcome.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Ezra
Top achievements
Rank 1
answered on 17 Nov 2020, 02:59 PM

Hello Neli,

     

0
Ezra
Top achievements
Rank 1
answered on 17 Nov 2020, 03:02 PM

That was a mistake.

 

So, the field that I am receiving from my datasource is a string that comes in as this:

"Test Field: Answer\r\nAnother Test Field: Another Answer\r\nYet Another Test Field: Yet Another Answer"

 

And then when I use it in a report item it is automatically formatted as 

"Test Field: Answer

Another Test Field: Another Answer

Yet Another Test Field: Yet Another Answer"

 

And attempting to use Replace(__, "\r\n", "") does not work.

 

What I would like is to format the string as:

"Test Field: Answer Another Test Field: Another Answer Yet Another Test Field: Yet Another Answer"

0
Mads
Telerik team
answered on 20 Nov 2020, 10:02 AM

Hi, Ezra

So the newline '/r/n' gets parsed and saved in a different way once brought into the report.

A solution to removing these spaces once the data is inside the report is to use the Replace function. For the data-source, create a new Calculated Field where we replace the newline with one space like shown in this screenshot

You can see how the function in the expression has an actual linebreak as part of its first parameter. 

I hope this information solves your issue. Let me know if it did, if you run into challenges, or have any other questions.

Regards, Mads Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Ezra
Top achievements
Rank 1
answered on 20 Nov 2020, 03:40 PM

Hello Mads,

 

This solution works great! Thank you for the help!

Tags
Report Designer (standalone)
Asked by
Ezra
Top achievements
Rank 1
Answers by
Ezra
Top achievements
Rank 1
Neli
Telerik team
Mads
Telerik team
Share this question
or