cancel
Showing results for 
Search instead for 
Did you mean: 

Text wrap in ObjectAttribute in ObjectListItem in sap ui5

former_member187069
Participant
0 Kudos

Hi All,

I have a list with sap.m.ObjectListItem control. I have an ObjectAttribute with a long text(as shown in the below pic). But the text doesnt get wrapped automatically. How can the text be wrapped and shown? sap.m.text - wrap is by default set to true..but not sure why this happens. Please advice. Thanks

Vishnupriya

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Vishnupriya,

I tried with a list having objectList with the objectAttribute example, wrapping is working fine for me.

Please refer the link.

Check with the version of SAP UI5 you are using.

you can check the version of SAP UI5 you are using by typing sap.ui.version in console.

In the version 1.20 this has been fixed. Please refer the Release notes.

thanks,
Shubham

Answers (2)

Answers (2)

chndn
Explorer
0 Kudos

Alternate approach would probably be just keeping first attribute empty and add another ObjectAttribute below that.

Somewhat like this...

<attributes>

<ObjectAttribute text="" />

<ObjectAttribute text="Long text to be shown here in this field with wrap" wrapping="true" />

</attributes>

Hope it helps!

Former Member
0 Kudos

I am using version 1.30 of SAPUI5 and I am having this same issue where the content of an ObjectAttribute is not wrapping...

Has anyone had this problem on 1.30 and managed to solve it?

Thank you

saivellanki
Active Contributor
0 Kudos

Hi Lindsay,

Text wrapping for ObjectAttribute in ObjectListItem was supported till 1.24 version and that too for maxLines:2. For current version it supports maxLines:1 if you place it in a Object List Item.

See this example which uses 1.24: JS Bin - Collaborative JavaScript Debugging . As you can see it shows only 2 lines and after that the text is not wrapped.

For Object attributes, the text characters should not be more. But still if there is a hard requirement to display more characters in the object attribute, then we have to check a work around for it.


Yes, indeed there is a work around for this.

See this sample: JS Bin - Collaborative JavaScript Debugging

Code that will increase the max lines of Object Attribute -


list.addEventDelegate({

onAfterRendering: function(oEvent) {

//Get the ObjectAttributes placed in the list

  var oObjectAttributes = $('#oList').find('.sapMObjectAttributeDiv');

  $.each(oObjectAttributes, function(index, item) {

    var oObjectAttributeID = sap.ui.getCore().byId(oObjectAttributes[index].id);

//Set the Max Lines value depending on your requirement

    oObjectAttributeID.getAggregation("_textControl").setProperty("maxLines", 10);

   });

  }

}, list);

Regards,

Sai Vellanki.

Former Member
0 Kudos

Thank you Sai, this looks great, I will try this