-5

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

Alex Tartan
  • 6,736
  • 10
  • 34
  • 45
techie
  • 1
  • 1
  • 2
  • 2
    Hi techie, not understanding what you want to know – Tuhin Jun 10 '15 at 06:20
  • As I am new to this technology . I am unable to understand following points 1 How to use BAR in XML view 2 The purpose of Custom data and its role inside the BAR Tag. Thanks – techie Jun 11 '15 at 07:37
  • You can use customData when need pass extra info to any logic. Example: When you has a menu, and each item has your target. So, in controller you resolve additional value of MenuItem, and trigger correctly route. – otaviodecampos Jan 22 '18 at 14:12
  • Here is another example of how `CustomData` can be leveraged: https://stackoverflow.com/a/42232902/ – Boghyon Hoffmann Apr 10 '18 at 23:53

1 Answers1

3

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

Tuhin
  • 3,335
  • 2
  • 16
  • 27