sap.ui.core.Element.create(vData, oKeyInfo?)
Creates a new Element from the given data.
If vData is an Element already, that element is returned. If vData is an object (literal), then a new element is created with vData as settings. The type of the element is either determined by a "Type" entry in the vData or by a type information in the oKeyInfo object
Parameters:
{sap.ui.core.Element|object} | vData | the data to create the element from |
{object} | oKeyInfo? | an entity information (e.g. aggregation info) |
{string} | oKeyInfo.type? | type info for the entity |
sap.ui.core.Element.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.Element with name
sClassName
and enriches it with the information contained in
oClassInfo
.
oClassInfo
might contain the following:
The prototype object of the newly created class uses the same prototype as instances of the base class (prototype chaining).
A metadata object is always created, even if there is no metadata
entry in the oClassInfo
object. A getter for the metadata is always attached to the prototype and to the class (constructor function) itself.
Last but not least, with the third argument FNMetaImpl
the constructor of a metadata class can be specified. Instances of that class will be used to represent metadata for the newly created class and for any subclass created from it. Typically, only frameworks will use this parameter to enrich the metadata for a new class hierarchy they introduce (as done by Element).
Parameters:
{string} | sClassName | name of the class to be created |
{object} | oClassInfo? | structured object with informations about the class |
{function} | FNMetaImpl? | constructor function for the metadata object. If not given, it defaults to sap.ui.core.ElementMetadata. |
- Since:
- 1.3.1
Returns:
{function} | the created class / constructor function |
Returns a metadata object for class sap.ui.core.Element.
Returns:
Returns the best suitable DOM node that represents this Element wrapped as jQuery object. I.e. the element returned by
sap.ui.core.Element#getDomRef is wrapped and returned.
If an ID suffix is given, the ID of this Element is concatenated with the suffix (separated by a single dash) and the DOM node with that compound ID will be wrapped by jQuery. This matches the UI5 naming convention for named inner DOM nodes of a control.
Parameters:
{string} | sSuffix? | ID suffix to get a jQuery object for |
Returns:
{jQuery} | The jQuery wrapped element's DOM reference |
Adds some customData to the aggregation customData
.
Parameters:
Returns:
Adds some dependent to the aggregation dependents
.
Parameters:
- Since:
- 1.19
Returns:
Adds a delegate that listens to the events that are fired on this element (as opposed to events which are fired BY this element).
When this element is cloned, the same delegate will be added to all clones. This behavior is well-suited for applications which want to add delegates that also work with templates in aggregation bindings. For control development the internal "addDelegate" method which does not clone delegates by default may be more suitable, as typically each control instance takes care of its own delegates.
To avoid double registrations, all registrations of the given delegate are first removed and then the delegate is added.
Important: If event delegates were added the delegate will still be called even if the event was processed and/or cancelled via preventDefault
by the Element or another event delegate. preventDefault
only prevents the event from bubbling. It should be checked e.g. in the event delegate's listener whether an Element is still enabled via getEnabled
. Additionally there might be other things that delegates need to check depending on the event (e.g. not adding a key twice to an output string etc.).
Parameters:
{object} | oDelegate | the delegate object |
{object} | oThis? | if given, this object will be the "this" context in the listener methods; default is the delegate object itself |
- Since:
- 1.9.0
Returns:
applyFocusInfo(oFocusInfo)
Applies the focus info.
To be overwritten by the specific control method.
Parameters:
Bind the object to the referenced entity in the model, which is used as the binding context to resolve bound properties or aggregations of the object itself and all of its children relatively to the given path. If a relative binding path is used, this will be applied whenever the parent context changes.
Parameters:
{string|object} | vPath | the binding path or an object with more detailed binding options |
{string} | vPath.path | the binding path |
{object} | vPath.parameters? | map of additional parameters for this binding |
{string} | vPath.model? | name of the model |
{object} | vPath.events? | map of event listeners for the binding events |
{object} | mParameters? | map of additional parameters for this binding (only taken into account when vPath is a string in that case the properties described for vPath above are valid here). |
Returns:
Clone delegates
Parameters:
{string} | sIdSuffix? | a suffix to be appended to the cloned element id |
{string[]} | aLocalIds? | an array of local IDs within the cloned hierarchy (internally used) |
Returns:
data()
Attaches custom data to an Element or retrieves attached data.
Usage: data("myKey", myData) attaches myData (which can be any JS data type, e.g. a number, a string, an object, or a function) to this element, under the given key "myKey". If the key already exists,the value will be updated.
data("myKey", myData, writeToDom) attaches myData to this element, under the given key "myKey" and (if writeToDom is true) writes key and value to the HTML. If the key already exists,the value will be updated. While oValue can be any JS data type to be attached, it must be a string to be also written to DOM. The key must also be a valid HTML attribute name (it must conform to sap.ui.core.ID and may contain no colon) and may not start with "sap-ui". When written to HTML, the key is prefixed with "data-".
data("myKey") retrieves whatever data has been attached to this Element (using the key "myKey") before
data("myKey", null) removes whatever data has been attached to this Element (using the key "myKey") before
data(null) removes all data
data() returns all data, as a map
destroy(bSuppressInvalidate?)
Cleans up the resources associated with this element and all its children.
After an element has been destroyed, it can no longer be used in the UI!
Applications should call this method if they don't need the element any longer.
Parameters:
{boolean} | bSuppressInvalidate? | if true, the UI element is not marked for redraw |
Destroys all the customData in the aggregation customData
.
Returns:
Destroys all the dependents in the aggregation dependents
.
- Since:
- 1.19
Returns:
Destroys the layoutData in the aggregation layoutData
.
Returns:
Destroys the tooltip in the aggregation named tooltip
.
Returns:
enhanceAccessibilityState(oElement, mAriaProps): object
Allows the parent of a control to enhance the aria information during rendering.
This function is called by the RenderManager's writeAccessibilityState method for the parent of the currently rendered control - if the parent implements it.
Parameters:
{sap.ui.core.Element} | oElement | the Control/Element for which aria properties are rendered |
{object} | mAriaProps | map of aria properties keyed by there name (withour prefix "aria-") |
Returns:
{object} | map of enhanced aria properties |
exit()
Cleans up the element instance before destruction.
Applications must not call this hook method directly, it is called by the framework when the element is destroyed.
Subclasses of Element should override this hook to implement any necessary cleanup.
Searches and returns an array of child elements and controls which are referenced within an aggregation or aggregations of child elements/controls. This can be either done recursive or not.
Take care: this operation might be expensive.
Parameters:
{boolean} | bRecursive | true, if all nested children should be returned. |
Returns:
Fires the given event and notifies all listeners. Listeners must not change the content of the event.
Parameters:
{string} | sEventId | the event id |
{object} | mParameters | the parameter map |
Returns:
focus()
Sets the focus to the stored focus DOM reference
Gets content of aggregation
customData
.
Custom Data, a data structure like a map containing arbitrary key value pairs.
Returns:
Gets content of aggregation
dependents
.
Dependents are not rendered, but their databinding context and lifecycle are bound to the aggregating Element.
- Since:
- 1.19
Returns:
getDomRef(sSuffix?): Element
Returns the best suitable DOM Element that represents this UI5 Element. By default the DOM Element with the same ID as this Element is returned. Subclasses should override this method if the lookup via id is not sufficient.
Note that such a DOM Element does not necessarily exist in all cases. Some elements or controls might not have a DOM representation at all (e.g. a naive FlowLayout) while others might not have one due to their current state (e.g. an initial, not yet rendered control).
If an ID suffix is given, the ID of this Element is concatenated with the suffix (separated by a single dash) and the DOM node with that compound ID will be returned. This matches the UI5 naming convention for named inner DOM nodes of a control.
Parameters:
{string} | sSuffix? | ID suffix to get the DOMRef for |
Returns:
{Element} | The Element's DOM Element sub DOM Element or null |
Get the element binding object for a specific model
Parameters:
{string} | sModelName | the name of the model |
Returns:
getFocusDomRef(): Element
Returns the DOM Element that should get the focus.
To be overwritten by the specific control method.
Returns:
{Element} | Returns the DOM Element that should get the focus |
getFocusInfo()
Returns an object representing the serialized focus information To be overwritten by the specific control method
Gets content of aggregation
layoutData
.
Defines the layout constraints for this control when it is used inside a Layout. LayoutData classes are typed classes and must match the embedding Layout. See VariantLayoutData for aggregating multiple alternative LayoutData instances to a single Element.
Returns:
getMetadata(): object
Returns the runtime metadata for this UI element.
When using the defineClass method, this function is automatically created and returns a runtime representation of the design time metadata.
Returns:
{object} | runtime metadata |
Returns the tooltip for this element if any or an undefined value. The tooltip can either be a simple string or a subclass of
sap.ui.core.TooltipBase.
Callers that are only interested in tooltips of type string (e.g. to render them as a title
attribute), should call the convenience method getTooltip_AsString instead. If they want to get a tooltip text no matter where it comes from (be it a string tooltip or the text from a TooltipBase instance) then they could call getTooltip_Text instead.
Returns:
getTooltip_AsString(): string
Returns the tooltip for this element but only if it is a simple string. Otherwise an undefined value is returned.
Returns:
{string} | string tooltip or undefined |
getTooltip_Text(): string
Returns the main text for the current tooltip or undefined if there is no such text. If the tooltip is an object derived from sap.ui.core.Tooltip, then the text property of that object is returned. Otherwise the object itself is returned (either a string or undefined or null).
Returns:
{string} | text of the current tooltip or undefined |
indexOfCustomData(oCustomData): int
Checks for the provided sap.ui.core.CustomData
in the aggregation customData
. and returns its index if found or -1 otherwise.
Parameters:
Returns:
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
indexOfDependent(oDependent): int
Checks for the provided sap.ui.core.Element
in the aggregation dependents
. and returns its index if found or -1 otherwise.
Parameters:
- Since:
- 1.19
Returns:
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
init()
Initializes the element instance after creation.
Applications must not call this hook method directly, it is called by the framework while the constructor of an element is executed.
Subclasses of Element should override this hook to implement any necessary initialization.
Inserts a customData into the aggregation customData
.
Parameters:
{sap.ui.core.CustomData} | oCustomData | the customData to insert; if empty, nothing is inserted |
{int} | iIndex | the 0 -based index the customData should be inserted at; for a negative value of iIndex , the customData is inserted at position 0; for a value greater than the current size of the aggregation, the customData is inserted at the last position |
Returns:
Inserts a dependent into the aggregation dependents
.
Parameters:
{sap.ui.core.Element} | oDependent | the dependent to insert; if empty, nothing is inserted |
{int} | iIndex | the 0 -based index the dependent should be inserted at; for a negative value of iIndex , the dependent is inserted at position 0; for a value greater than the current size of the aggregation, the dependent is inserted at the last position |
- Since:
- 1.19
Returns:
Removes all the controls from the aggregation
customData
.
Additionally, it unregisters them from the hosting UIArea.
Returns:
Removes all the controls from the aggregation
dependents
.
Additionally, it unregisters them from the hosting UIArea.
- Since:
- 1.19
Returns:
Removes a customData from the aggregation customData
.
Parameters:
Returns:
Removes a dependent from the aggregation dependents
.
Parameters:
- Since:
- 1.19
Returns:
Removes the given delegate from this element.
This method will remove all registrations of the given delegate, not only one.
Parameters:
{object} | oDelegate | the delegate object |
- Since:
- 1.9.0
Returns:
rerender()
This triggers immediate rerendering of its parent and thus of itself and its children.
As sap.ui.core.Element
"bubbles up" the rerender, changes to child-Elements
will also result in immediate rerendering of the whole sub tree.
setLayoutData(oLayoutData)
Sets the
sap.ui.core.LayoutData defining the layout constraints for this control when it is used inside a layout.
Parameters:
setTooltip(vTooltip)
Sets a new tooltip for this object. The tooltip can either be a simple string (which in most cases will be rendered as the
title
attribute of this Element) or an instance of
sap.ui.core.TooltipBase.
If a new tooltip is set, any previously set tooltip is deactivated.
Parameters:
toString(): string
Returns a simple string representation of this element.
Mainly useful for tracing purposes.
Returns:
{string} | a string descripition of this element |
Removes the defined binding context of this object, all bindings will now resolve relative to the parent context again.
Parameters:
Returns:
sap.ui.core.Element.defineClass(sClassName, oStaticInfo, fnMetaImpl?): object
Creates metadata for an UI Element by extending the Object Metadata.
In addition to the entries defined by sap.ui.base.Object.defineClass, the following entries can be specified in the static info object:
- library: {string} name of the library that contains the element/control
- properties: a map of property info objects, mapped by the property name Info object should contain the following information
- name {string} name of the property (redundant to map key)
- type {string} type of the property
- [defaultValue] {any} default value of the property. Can be omitted
- aggregations: a map of aggregation info objects, mapped by the aggregation name Info object should contain the following information
- name {string} name of the aggregation, singular for 0..1, plural for 0..n
- type {string} type of the aggregated controls/elements
- multiple {boolean}
- singularName {string} singular name for 0..n aggregations
- associations: a map of association info objects, mapped by the association name Info object should contain the following information
- name {string} name of the association, singular for 0..1, plural for 0..n
- type {string} type of the associated controls/elements
- multiple {boolean}
- singularName {string} singular name for 0..n associations
- events: map from event names to event names
Parameters:
{string} | sClassName | name of the class to build the metadata for |
{object} | oStaticInfo | static information used to build the metadata |
{function} | fnMetaImpl? | constructor to be used for the metadata |
- Deprecated:
- Since 1.3.1. Use the static
extend
method of the desired base class (e.g. sap.ui.core.Element.extend)
Returns:
{object} | the created metadata |
See:
This function either calls set[sPropertyName] or get[sPropertyName] with the specified property name depending if an oValue
is provided or not.
Parameters:
{string} | sPropertyName | name of the property to set |
{any} | oValue? | value to set the property to |
- Deprecated:
- Since 1.28.0 The contract of this method is not fully defined and its write capabilities overlap with applySettings
Returns:
{any|sap.ui.core.Element} | Returns this to allow method chaining in case of setter and the property value in case of getter |