简体   繁体   English

如何在 PCF 组件的控制清单中指定枚举值的排序顺序?

[英]How can I specify the sort order of Enum values in the control manifest of a PCF component?

Let's assume having the following size property of type Enum in the ControlManifest.Input.xml of a PCF component (Microsoft Power Apps component framework):假设在 PCF 组件(Microsoft Power Apps 组件框架)的ControlManifest.Input.xml中具有以下Enum类型的size属性:

    <property name="size" display-name-key="size" of-type="Enum" usage="input" default-value="48">
      <value name="10">10</value>
      <value name="36">36</value>
      <value name="100">100</value>
    </property>

When used in a canvas App, the order of the values in the combobox for selecting the value of the property seems to be always in alphabetic order:在 canvas App 中使用时,combobox 中用于选择属性值的值的顺序似乎总是按字母顺序排列:

10
100
36

Is there any way to declare a different order?有什么办法可以声明不同的订单吗?

The documentation doesn't mention the value tag at all: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/property该文档根本没有提及价值标签: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/property

The best way I found so far is to pad the name with zeros:到目前为止我发现的最好方法是用零填充名称:

    <property name="size" display-name-key="size" of-type="Enum" usage="input" default-value="48">
      <value name="010">10</value>
      <value name="036">36</value>
      <value name="100">100</value>
    </property>

This will let the values appear in the correct order:这将使值以正确的顺序出现:

10
36
100

I can even give them a more specific display name while keeping the correct order:我什至可以给他们一个更具体的显示名称,同时保持正确的顺序:

    <property name="size" display-name-key="size" of-type="Enum" usage="input" default-value="48">
      <value name="010" display-name-key="10px">10</value>
      <value name="036" display-name-key="36px">36</value>
      <value name="100" display-name-key="100px">100</value>
    </property>

The only draw-back is that, as you can see on the advanced property editing tab, the selected value is stored with leading zeros:唯一的缺点是,正如您在高级属性编辑选项卡上看到的那样,所选值以前导零存储:

'NAMESPACE.ComponentName.PropertyName'.'010'
'NAMESPACE.ComponentName.PropertyName'.'036'
'NAMESPACE.ComponentName.PropertyName'.'100'

It might be a matter of personal taste that I don't like this representation of the values.我不喜欢这种价值观的表达方式,这可能是个人品味的问题。 So far it I can't find any draw-back caused by the leading zeros, it just doesn't feel right for my developers heart.到目前为止,我找不到任何由前导零引起的缺点,它只是不适合我的开发人员的心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对 PowerApps 组件 (PCF) 中的数据集应用排序 - Apply a sort to a dataset in a PowerApps component (PCF) 如何修复 Azure Maps PCF 组件绘图工具偏移 - How to Fix Azure Maps PCF Component Drawing Tools Offset 显示选项集列表的 PCF 控件 - PCF control that shows list of OptionSets 在 PowerApps PCF 组件中查询 SQL - Query SQL in PowerApps PCF component 如何使用 pcf 控件 D365 创建自定义保存按钮 - How to create custom save button using pcf control D365 如何在排序之前使用条件&#39;if&#39;对sortbycolumns进行排序? - How can I sortbycolumns with a conditional 'if' before the sort? 有没有办法将数据自动加载到 PowerApps 组件框架 (PCF) 中的数据集? - Is there a way to auto load data to a dataset in PowerApps Component Framework (PCF)? AG Grid PCF Control - CSS 不带 css 装载机 - AG Grid PCF Control - CSS without css loader 管理 Canvas PowerApp 中 PCF 代码组件上的“属性”选项卡 - Manage “Properties” tab on PCF code component in Canvas PowerApp 从 PCF 组件调用 Dynamics CRM Rest API,嵌入到模型驱动的应用程序中 - Calling Dynamics CRM Rest API from PCF component, Embedding in Model-Driven App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM