cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a line break to text property of the TimelineItem control in UI5 XML view?

0 Kudos

The escape character '\n' and Unicode character \u000a will only work in JavaScript. However, I'm trying to add a line break in XML view as below. But doesn't work.

<code><u:TimelineItem text="First Line\n Second Line"/>

Note \n works as expected for Text control in XML as well.

<code><Text text="First Line\n Second Line"/>
mantrishekar
Active Participant

Hi Manjunatha,

Write this text (First Line\n Second Line"/) in i18 n file and bind the value in view like below.

in i18n write like below.

propName = First Line\n Second Line

It will work.

<code><Texttext="{i18n>propName}"/>

Regards

Shekar.

0 Kudos

Thanks for the response, Mantri. This is a good workaround. But why doesn't work there?

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member627560
Discoverer

Hi Manjunatha,

in i18n write like below.

textA=A

textB=B

lineFeed = \n

It will work.

<code><Texttext="{i18n>textA} {i18n>lineFeed} {i18n>textB}"/>

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

This was a bug in SAPUI5 which was fixed in 1.44.5+. From the change log:

> [FIX] sap.suite.ui.commons.Timeline: Rendering of multiline text improved

For other controls, details, and a demo, see my answer in your other question How to Add a Line Break to Text.

SergioG_TX
Active Contributor
0 Kudos

this works for me:

<Text text="line line\n line two" />

<c:TimelineItem text="one one one\n two two" />

make sure you declare the namespace for the sap.suite.ui.commons

xmlns:c="sap.suite.ui.commons" in your view declaration

Hi, Sergio,

The namespace declared in my view is sap.suite.ui.commons only. It is surprising to know that it works for you.

However, the workaround for this problem is to bind the text from i18n file.