Class sap.ui.core.CustomDataModule: sap/ui/core/CustomData
Contains a single key/value pair of custom data attached to an Element. See method data().
sClassName
and enriches it with the information contained in oClassInfo
. Accepts an object literal mSettings
that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.
The supported settings are:
- Properties
- key : string
- value : any
- writeToDom : boolean (default: false)
In addition, all settings applicable to the base type sap.ui.core.Element can be used as well.
{string} | sId? | id for the new control, generated automatically if no id is given |
{object} | mSettings? | initial settings for the new control |
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.core.Element.extend.
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
key
. The key of the data in this CustomData object. When the data is just stored, it can be any string, but when it is to be written to HTML (writeToDom == true) then it must also be a valid HTML attribute name (it must conform to the sap.ui.core.ID type and may contain no colon) to avoid collisions, it also may not start with "sap-ui". When written to HTML, the key is prefixed with "data-". If any restriction is violated, a warning will be logged and nothing will be written to the DOM.
{string} | Value of property key |
value
. The data stored in this CustomData object. When the data is just stored, it can be any JS type, but when it is to be written to HTML (writeToDom == true) then it must be a string. If this restriction is violated, a warning will be logged and nothing will be written to the DOM.
{any} | Value of property value |
writeToDom
. If set to "true" and the value is of type "string" and the key conforms to the documented restrictions, this custom data is written to the HTML root element of the control as a "data-*" attribute. If the key is "abc" and the value is "cde", the HTML will look as follows: <SomeTag ... data-abc="cde" ... > Thus the application can provide stable attributes by data binding which can be used for styling or identification purposes. ATTENTION: use carefully to not create huge attributes or a large number of them.
Default value is false
.
- Since:
- 1.9.0
{boolean} | Value of property writeToDom |
key
. The key of the data in this CustomData object. When the data is just stored, it can be any string, but when it is to be written to HTML (writeToDom == true) then it must also be a valid HTML attribute name (it must conform to the sap.ui.core.ID type and may contain no colon) to avoid collisions, it also may not start with "sap-ui". When written to HTML, the key is prefixed with "data-". If any restriction is violated, a warning will be logged and nothing will be written to the DOM.
When called with a value of null
or undefined
, the default value of the property will be restored.
{string} | sKey | New value for property key |
{sap.ui.core.CustomData} | Reference to this in order to allow method chaining |
value
. The data stored in this CustomData object. When the data is just stored, it can be any JS type, but when it is to be written to HTML (writeToDom == true) then it must be a string. If this restriction is violated, a warning will be logged and nothing will be written to the DOM.
When called with a value of null
or undefined
, the default value of the property will be restored.
{any} | oValue | New value for property value |
{sap.ui.core.CustomData} | Reference to this in order to allow method chaining |
writeToDom
. If set to "true" and the value is of type "string" and the key conforms to the documented restrictions, this custom data is written to the HTML root element of the control as a "data-*" attribute. If the key is "abc" and the value is "cde", the HTML will look as follows: <SomeTag ... data-abc="cde" ... > Thus the application can provide stable attributes by data binding which can be used for styling or identification purposes. ATTENTION: use carefully to not create huge attributes or a large number of them.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
{boolean} | bWriteToDom | New value for property writeToDom |
- Since:
- 1.9.0
{sap.ui.core.CustomData} | Reference to this in order to allow method chaining |