Skip to content

Commit

Permalink
OpenUI5 Documentation Update 19.01.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
openui5bot committed Jan 19, 2024
1 parent ff980c2 commit df0f741
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/Defining_Control_Properties_ac56d92.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ enumeration \(enum\)

Derived from the built-in type `string`.

Restricted subtypes can be derived that limit their valid values to a fixed set of values \(enumeration\). An `enum` type is defined through an object literal whose keys represent the allowed values.
Restricted subtypes can be derived that limit their valid values to a fixed set of values \(enumeration\).

An `enum` type is defined through an object literal whose keys represent the allowed values and must be registered by calling the `DataType.registerEnum()` method.

Restrictions:

Expand All @@ -212,18 +214,19 @@ Restrictions:

This was an early design decision in OpenUI5 and framework code relies on it. That code might fail for enumerations that don’t obey these restrictions.

To reference an `enum` type in a property definition, its global name must be used \(like `sap.m.ValueColor` in the example below\).
To reference an `enum` type in a property definition, its string name must be used \(like `sap.m.ValueColor` in the example below\).

Example for creating an enumeration:

```js
sap.ui.define(["sap/ui/baseDataType"], (DataType) => {
/**
* Enumeration of possible value color settings.
*
* @enum {string}
* @public
*/
sap.m.ValueColor = {
const ValueColor = {

/**
* Neutral value color.
Expand All @@ -234,6 +237,9 @@ sap.m.ValueColor = {
};

// Register enum type
DataType.registerEnum("sap.m.ValueColor", ValueColor);
});
```

Example for defining a property using an enumeration:
Expand Down

0 comments on commit df0f741

Please sign in to comment.