Class sap.ui.core.CustomDataModule: sap/ui/core/CustomData

extends Element

Contains a single key/value pair of custom data attached to an Element. See method data().

Constructor Summary
new sap.ui.core.CustomData(sId?, mSettings?)Constructor for a new CustomData.
Method Summary
sap.ui.core.CustomData.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.core.CustomData with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.core.CustomData.getMetadata()Returns a metadata object for class sap.ui.core.CustomData.
getKey()Gets current value of property key.
getValue()Gets current value of property value.
getWriteToDom()Gets current value of property writeToDom.
setKey(sKey)Sets a new value for property key.
setValue(oValue)Sets a new value for property value.
setWriteToDom(bWriteToDom)Sets a new value for property writeToDom.
Constructor Detail
new sap.ui.core.CustomData(sId?, mSettings?)
Constructor for a new CustomData.

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:

In addition, all settings applicable to the base type sap.ui.core.Element can be used as well.

Parameters:
{string}sId? id for the new control, generated automatically if no id is given
{object}mSettings? initial settings for the new control
Method Detail
sap.ui.core.CustomData.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.CustomData with name 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.

Parameters:
{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
Returns:
{function} Created class / constructor function
sap.ui.core.CustomData.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.core.CustomData.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
getKey(): string
Gets current value of property 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.

Returns:
{string} Value of property key
getValue(): any
Gets current value of property 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.

Returns:
{any} Value of property value
getWriteToDom(): boolean
Gets current value of property 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
Returns:
{boolean} Value of property writeToDom
setKey(sKey): sap.ui.core.CustomData
Sets a new value for property 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.

Parameters:
{string}sKey New value for property key
Returns:
{sap.ui.core.CustomData} Reference to this in order to allow method chaining
setValue(oValue): sap.ui.core.CustomData
Sets a new value for property 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.

Parameters:
{any}oValue New value for property value
Returns:
{sap.ui.core.CustomData} Reference to this in order to allow method chaining
setWriteToDom(bWriteToDom): sap.ui.core.CustomData
Sets a new value for property 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.

Parameters:
{boolean}bWriteToDom New value for property writeToDom
Since:
1.9.0
Returns:
{sap.ui.core.CustomData} Reference to this in order to allow method chaining