cancel
Showing results for 
Search instead for 
Did you mean: 

Get Active Span in GridData

Former Member
0 Kudos

Hi,

I want to create a situation where the Text Alignment  of my label is based on the current Span setting of the component. My label is defined as follows:


var label = new sap.m.Label({

     text: "test",

     textAlign: sap.ui.core.TextAlign.Right,

     layoutData: new sap.ui.layout.GridData({

          span: "L1 M1 S12"

     })

});

Now if the label is set to display using the S12 span (based on the current screen size), then I would like to use:


label.setProperty("textAlign", sap.ui.core.TextAlign.Center)

Is it possible to get the current Span setting being applied to the label?

Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

karthikarjun
Active Contributor
0 Kudos

Hi Albert,

Will this help? http://jsbin.com/soyiye/edit?html,js,output

Thanks,

Karthik A

Former Member
0 Kudos

Hi,

Thank you for your reply. Unfortunately I do not understand what the jsbin is supposed to show? The text says it will span 4 cols on large, 6 on medium and 12 on small, but the span is set to "L12 M12 S12" indicating that it will spand over 12 cols for all 3 screen sizes?

also My main problem is not that I can't set it to the span, my problem is that I want to dynamically find the current screen size that is being used. For example, if the current screen is seen as Large, then I want to set the Text alignment to Right, if the current screen is seen as Small, then I want to align the text to the left.

Regards

karthikarjun
Active Contributor
0 Kudos

By Mistake I placed wrong one.

will this help? http://jsbin.com/dawapo/edit?js,output

Based on the screen size sap will add css classes automatically.

I appended my changes here.

Thanks,

Karthik A