Enumeration

This post is referring to Vahana 2 (beta version). To check the document for production, please go to vDesigner-v1.0

An enumeration is a programming concept. In the Data Modeler module, an enumeration can be treated as an object or data type. The enumeration type is also abbreviated as enum. In the enum object, you need to define the following:

  • Key
  • Value
  • Parent Key

In the enum object, the key represents the name of the enum member, while the value of a key represents the value. Thus, the enum object contains a collection of key/value pairs. You can see the a sample of enum object as follows:

A sample enum type:

You can use the enum object to display the list of values in the drop down list, radio button (mutually exclusive buttons), check box, and other list based elements. The Data Model module provides a full-fledged UI-based properties to declare and define an enum object. Unlike conventional programming languages, such as Java, Python, and others, you need not to write the code base to define the enum object in Data Modeler.

You can start with creating a new enum type.

Creating a New Enum

You can define the enum object as follows:

  1. On the Data Modeler page, see the top panel.
  1. In the top panel, click Create Enumeration to display the Create Enumeration dialog box.
  2. In the Create Enumeration dialog box, enter values in the related boxes as follows:
FieldDescription
KeyIn this box, enter the key name (for example, Demo_enum) of the enum. The Data Modeler module uses the key name as a name identifier to manage the enum object.
NameAfter you enter the key name in the Key box, the Name box displays the same name. You can also enter different name (for example, Demo_enum1) in the Name box. The value that you enter in the Name box is displayed as the label name on the application.
TagsIn this box, enter a random value (for example, enum_for_vDesigner). You can use a tag to manage an enum object or group of enum objects at the Data Modeler level. In the details of the enum, a tag works as an identifier that you can use to search and find one or more enum.
DescriptionIn this box, enter a brief reason to create the enum.
  1. After you enter the details of the enum, click Create to create a new enum type.

Initializing an Enum

In this section, you will learn how to define the key/value pair in the enum. In the Data Modeler module, an enum contains the following:

  • The parent key that contains a set of key/value pairs
  • A key that is used to manage the related value at the back-end level
  • A value of a key that the application displays in the element

Assume a scenario where you want to display four metro cities in the drop down list. These four cities are Delhi, Bengaluru, Chennai, and Hyderabad. To display these four cities, you can define the key/value pair as follows:

To define the key/value pair in the enum:

  1. On the Data Modeler page, under the top panel, click the Enumeration tab to display the list of existing enumeration types.
  1. In the list, search and find the enumeration that you want to initialize.
  2. After you find the enumeration, double-click it to display the <<enumeration name>> page.
  3. On the <<enumeration name>> page, enter values in the related boxes as follows:
BoxDescription
KeyIn this box, enter the key name. The enum type uses the key to maintain its value at the database level. The key or key name is managed at the back-end level.

Following the scenario, you want to display four cities in the drop-down list. Enter DL in the Key box for Delhi, and then click Add New to enter BN in the Key box for Bengaluru.
NameIn this box, enter a value (for example, Delhi, Bengaluru, and others) that you want to display in the element.
Parent KeyIn this box, enter a name that works as a container or class for the group of key/value pairs. Because you want to display four different Indian cities in the element, you can enter City in the Parent Key box.

In the Parent Key box, this City keyword serves as a class or container that contains multiple key/value pairs.
  1. After you enter the first pair of the key and value in the Key and Value boxes, click Add New to enter another key and value pair in related boxes.
  1. After you enter all key/value pairs, click Save to define the structure of the enum.

Other Miscellaneous Functions

FunctionDescription
DuplicateThis functionality allows you to create a copy of the current enum type with the same set of key/value pair. You can use this functionality when you want to use the current data structure of an enum type with a small customization based on the requirement.

In this scenario, you can create a copy of an existing enum and then use the same set of key/value pairs or customize it by adding other key/value pairs or removing the existing key/value pairs. You are recommended to use this functionality when you want to create two enum types with similar types of data structure.

To create a copy of the enum type:
a. In the top panel, click Duplicate to display the Duplicate <<enum’s name>> dialog box.
b. In the dialog box, enter the key name (for example, Demo_enum1) in the Key box.
c. The Name box automatically displays the same key name that you entered in the Key box. If you want, you can also change the value in the Name box.
d. After you enter the key and name of a new enum, click Duplicate in the Duplicate <<enum’s name>> dialog box to create a copy of the enum.
DeleteUse this functionality when you want to delete the currently accessed enum. To delete the enum:
a. In the top panel, click Delete to display the Delete <<enum’s name>> dialog box.
b. In the dialog box, click Delete to delete the currently accessed enum.

Using Enumeration in Application

After you create an enumeration, you can bind it and then map its value to an element. When the application loads a page or an end-user performs the function on the element, it fetches the data values from the enumeration and then displays them to the user. In the vDesigner module, many elements have the Input Source property that allows to map an entity, attribute, or an enumeration so that the element displays the data values from the mapped entity, attribute, or enumeration.

These elements are the drop-down list, check box group, radio group, and others. In these elements, the Input Source property provides two options as follows:

  • Data Source:- This option allows you to map the entity or attribute to the element.
  • Enumeration:- This option allows you to map an enumeration to the element.

This section explains how to map an enumeration to the element.

To map the enumeration to the element:

  1. On the vDesigner canvas, drag an element (for example:- Dropdown) to the application page.
  2. On the application page, click the element to display its property panel.
  1. In the element’s property panel, see the Input Source property.
  2. Under Input Source, click the Enumeration tab to display the Select Master list.
  1. Click the Select Master list and then select an enumeration to map it to the selected element.
  1. Click Apply to save and apply the mapping between the enumeration and element.

Was this article helpful?
YesNo