Order enumeration values
Prerequisite: You must be familiar with the Syntax used in Tutorials and have already created an extension.
The iTop 3.1 brings new capabilities to order the values of a enumeration attribute.
Before 3.1 version, values of an enumeration were ordered alphabetically by code
Now, you can specify in the XML tag sort_type
,
which ordering method you want amongst
-
code: default value, same behavior as before 3.1
-
label: values are displayed by alphabetical order of labels (this means that the order can be different depending on the user language)
-
rank: this suppose that you specify a rank on each value
-
Values with rank are displayed first, followed by those without rank, using the code alphabetical order.
-
rank
is a new XML tag undervalues/value
in parallel of thecode
and thestyle
-
Order by label
- itop_design / classes / class@Incident / fields
-
<field id="origin" xsi:type="AttributeEnum"> <sort_type>label</sort_type> <values> <value id="in_person"><code>in_person</ code></value> <value id="chat"><code>chat</ code></value> <value id="mail"><code>mail</ code></value> <value id="phone"><code>phone</ code></value> <value id="portal"><code>portal</ code></value> <value id="monitoring"><code>monitoring</ code></value> </values> <sql>origin</sql> <default_value>phone</default_value> <is_null_allowed>true</is_null_allowed> <display_style>list</display_style> </field>
Order by rank
- itop_design / classes / class@UserRequest / fields
-
<field id="status" xsi:type="AttributeEnum"> <always_load_in_tables>true</always_load_in_tables> <sort_type>rank</sort_type> <values> <value id="new"> <code>new</ code> <rank>10</rank> <style> <main_color>$ibo-lifecycle-new-state-primary-color</main_color> <complementary_color>$ibo-lifecycle-new-state-secondary-color</complementary_color> <decoration_classes/> </style> </value> <value id="waiting_for_approval"> <code>waiting_for_approval</ code> <rank>20</rank> <style> <main_color>$ibo-lifecycle-waiting-state-primary-color</main_color> <complementary_color>$ibo-lifecycle-waiting-state-secondary-color</complementary_color> <decoration_classes>fas fa-hourglass-half</decoration_classes> </style> </value> <value id="approved"> <code>approved</ code> <rank>30</rank> <style> <main_color>$ibo-lifecycle-success-state-primary-color</main_color> <complementary_color>$ibo-lifecycle-success-state-secondary-color</complementary_color> <decoration_classes>fas fa-user-check</decoration_classes> </style> </value> ...
3_1_0/customization/order-enum.txt
ยท Last modified: 2023/08/31 12:41 (external edit)