Skip to Content
Former Member
Jul 07, 2013 at 05:54 AM

How to set style/Class for parent DOM Element


Hi all,

I am using SAPUI5 1.12.1 version

In vertical layout I am adding one label
I want to set class to parent element of label (Not to vertical layout control. But to the div which content label. )
for eg:

var oLabel = new sap.ui.commons.Label({text:"Name:", labelFor: oText});

var oButton = new sap.ui.commons.Button({text:"Submit", tooltip:"Submit value"});

var oLayout = new sap.ui.commons.layout.VerticalLayout("Layout1", {

content: [oLabel, oButton]


will generate HTML as follows

<div class="sapUiVlt sapuiVlt" data-sap-ui="Layout1" id="Layout1">

<div class="sapUiVltCell sapuiVltCell MyCustomClass">

<label class="sapUiLbl sapUiLblNowrap" style="text-align:left;" dir="Inherit" for="__field0" data-sap-ui="__label1" id="__label1">Name:</label>

<div class="sapUiVltCell sapuiVltCell">

<button class="sapUiBtn sapUiBtnNorm sapUiBtnS sapUiBtnStd" tabindex="0" aria-disabled="false"

role="button" title="Submit value" data-sap-ui="__button2" id="__button2" type="button">Submit</button>



I want to give style or class to parent Div("sapUiVltCell sapuiVltCell") of label element as "MyCustomClass" or want to add custom style as "background-color:#fefefe ;"

Also this vertical layout is always generated On click particular view. So how to set css to that auto-generated div on run time