数据展示数据源如何选择已经创建的枚举

0
database如何选择已经创建的enum
asked
3 answers
0

Hello Chaojie,


I believe what you are trying to do is select as a data source for a Data grid an enumeration, this is not possible a Data grid expects to receive an Entity value.


If your goal is to display the Enumeration values for a certain entity, select that entity as a data source and add a column to the data grid that displays for each row the Enumeration value.


If your goal is only to display the enumeration values you can do so in drop down or radio button, you can create a helper entity, add an attribute of the type enumeration and choose the enumeration you want to display, then on the page you can display this helper entity and show the Enumeration values like I said as a drop down or radio button.


Please let me know if the desired outcome is different and I can try to help you.

answered
0

我创建了一个辅助实体,并且添加了一个枚举类型的属性,然后在页面上选择下拉菜单显示枚举值,但是选择展示值的时候不知道该如何选择

answered
0

The simplest way to display Enumeration values in a Combo box is to use the enumeration directly as an attribute of an entity.


First, you need to create an Enumeration. For example, you can create an enumeration called EquipmentType. Inside this enumeration, you define the possible values, such as Laptop, Printer, and Scanner. An enumeration is essentially a fixed list of options used within the application.


Next, you use this enumeration as an attribute in an Entity. For example, assume you have an entity called Equipment. You add a new attribute named equipmentType and set its type to Enumeration → EquipmentType. This means that each Equipment record can store one of the values defined in the enumeration.


The next step is to use this entity on a Page. To do this, you add a Data View to the page. A Data View represents the Equipment object that is currently being viewed or edited. Any changes made on the page will be applied to this object.


Inside the Data View, you can add a Combo box. In the Combo box settings, set the Data source to Context. Context refers to the current Equipment object on the page. Then select the equipmentType attribute in the Store value / Attribute field.


Once this is configured, the Combo box will automatically list the enumeration values. When the user opens the Combo box, they will see options such as Laptop, Printer, and Scanner. When a user selects one of these options, the selected value will be stored in Equipment.equipmentType.


This is the simplest and most recommended approach for using enumerations in Mendix. There is no need to create an additional helper entity, and the Combo box will automatically display the enumeration values.


If this solution resolved your issue, please consider marking it as the Accepted Answer so it can help others facing the same problem.


answered