cancel
Showing results for 
Search instead for 
Did you mean: 

Use of raw HTML in controls

Former Member
0 Kudos

Hi,

is it possible to set raw HTML for a control? We want to display dynamic content which can contain e.g. HTML links.

In this examples the result should be a bold label, but the control is encoding the content (JSBin).

Example 1


var label1= view.byId("label1");

    label1.setText("<b>test</b>");

Example 2


<Label id="label2" text="&lt;b&gt;test&lt;/b&gt;" />    

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ludwig,

use HTML code as

<Page title="SAPUI5 App">
  <core:HTML id="html" content="<p>hello</p>"/>
  </Page>

Hope this will help you.

Former Member
0 Kudos

This is working! Thank you all.

JS Bin - Collaborative JavaScript Debugging

Answers (2)

Answers (2)

sebastianraemsch
Active Participant
0 Kudos

Hi Ludwig,

I think for this purpose you should use the sap.ui.core.HTML control.

See docu here: https://openui5.hana.ondemand.com/#docs/api/symbols/sap.ui.core.HTML.html

With a label this will not work. Of course you could create your own control which inherits from label but then you have to create the logic by your own.

You can have a look at the original source code for label control here:

https://github.com/SAP/openui5/tree/master/src/sap.m/src/sap/m

Note that the controls consists of 2 files, e.g. Label.js and LabelRenderer.js. If you create an inherited control you most probably have to adapt mainly the Renderer.

Best regards,

Sebastain

Former Member
0 Kudos

Hi Ludwig,

to make the content of the label bold you can use sap.m.LabelDesign.


Label label = new sap.m.Label();

label.setText("test");

label.setDesign(sap.m.LabelDesign.Bold);

or inside xml view


<Label id="label" design="Bold" text="test"/>

see SAPUI5 SDK - Demo Kit.

Regards,

Daniel

Former Member
0 Kudos

Hi Daniel,

i dont't want to style the label. I have dynamic HTML and i want to output the content raw without any encoding.