Use of customdata tag

2.6k Views Asked by At

Kindly let me know the use of tag customData I am unable to understand the following piece of code

<Bar id="myBar">
    <customData>
        <core:CustomData key="sap-ui-fastnavgroup" value="true"              writeToDom="true"/>
    </customData>
</Bar>

How to add title in the bar. I am newbie to UI5 technology Thanks

1

There are 1 best solutions below

0
On

customData can be used as an aggregation of a control that extends sap.ui.core.Element. Custom data are generally used as HTML data-* Attributes.

For example:

   var oTextEdit= new sap.ui.commons.TextField({
           //Properties
    });

    var oCustomData =new sap.ui.core.CustomData({
        key     : "fieldID",
        value   : "textfield1"
    });
    var oCustomDataEntyID =new sap.ui.core.CustomData({
        key     : "entitypropertyid",
        value   : "username"
    });
    oTextEdit.addCustomData(oCustomData);
    oTextEdit.addCustomData(oCustomDataEntyID);

    var aAllCustomData =  oTextEdit.getCustomData();
    $.each(aAllCustomData,function(index){
          console.log(aAllCustomData[index].key +" : "+aAllCustomData[index].value)
    });

https://openui5.hana.ondemand.com/#docs/api/symbols/sap.ui.core.Element.html