Marcus Wagner
Marcus Wagner

Reputation: 9

UI5 - Add Style Class in JSONView

I have a problem, how can add a new style class to a JSON-Control in OpenUI5 or SAPUI5? I can't find examples! I need the constructor syntax!

Here my response in JSON:

{
"Type": "sap.m.IconTabBar",
"id": "icontabbar_2cf94283-10ff-4b05-a912-5212a579f92e",
"items":[
    {
        "Type": "sap.m.IconTabFilter"
        "class": "tabtest"
        "content": [,…]
        "count": ""
        "icon": "sap-icon://message-information"
        "id": "icontabfilter_7e0ff4f0-9871-49da-9a4a-af048eb447a0"
        "key": "details"
        "text": "Details"
    }
]
}

Upvotes: 0

Views: 1991

Answers (2)

SiddP
SiddP

Reputation: 1663

To any controls whether they are predefined ones for example: DateTimePicker or TextView or it may be custom control you can use addStyleClass to add styles to your controls.

Here is an example:

Openui5 predefined control

new sap.ui.commons.TextView({
  text: "Title"
}).addStyleClass("myclass"),

Custom control

new my.control.Custom({
  text: "Title"
}).addStyleClass("myclass"),

Alternatively you can assign an id , you can add style class using jquery.

//for jsview
new sap.ui.commons.TextView("textviewid",{
  text: "Title"
});
//for xmlview
<Text id="textviewid" text="My Text" />
//Adding class in jquery
$("#textviewid").addClass("myclass");

or simply add class="myCustomClass" as stated by @cschuff

Upvotes: 1

cschuff
cschuff

Reputation: 5532

Just as an addition to SiddPs answer: If you use XMLView you can add classes like this:

<Text class="myCustomClass" text="My Text" />

Upvotes: 0

Related Questions