UiPath Documentation
activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

工作流活动

上次更新日期 2026年4月16日

下拉菜单的高级控件

The tutorials on this page demonstrate using drop-down lists with the UiPath Form Designer, inside the Create Form Task activity. The most used property for achieving the results in the tutorials is the FormData(Collection).

创建动态下拉列表

在要发送动态数据以填充表单操作内的下拉控件的工作流中使用它们。

With this method, a variable of the type List of Strings holds the values of the drop-down list instead of adding static values on the Data tab in the UiPath Form Designer.

在以下示例中,我们创建一个国家/地区的动态下拉列表,使用国家/地区列表初始化一个变量,并创建一个附加变量以捕获用户选择的国家/地区。

docs image

To create a dynamic drop-down:

  1. In the Create Form Task activity, click the ellipsis (...) to the right of FormData.
  2. 为动态下拉列表添加参数,如下所示:
    • 名称: countryList_dropdown

    • Direction: In

    • Type: List of Strings (List<String>)

    • Value: Press Ctrl + K and enter listOfCountries as the variable name.

      listOfCountries 变量包含下拉列表中的项目。

      备注:

      Array of Strings is also supported, but you must manually add the drop-down component in Form Designer and add the Field Key value.

  3. 如果要将用户选择返回到工作流,请添加另一个参数以捕获所选值:
    • 名称: country (下拉组件的字段键)
    • Direction: In/Out or Out
    • Type: String
    • Value: Press Ctrl + K and enter selectedCountry as the variable name.
  4. Click OK to close Form Data.
  5. Open the Variables panel and initialize listOfCountries with the default value new List(of string) from { "India", "Romania", "US" }.
    提示:

    You can also choose to populate listOfCountries through other activities instead of initializing it.

创建级联下拉列表

如果您希望一个下拉列表(父级)中的选择填充第二个下拉列表(子级)中的值,请在基于任务的表单中使用它们。

docs image

要创建级联下拉列表,请执行以下操作:

  1. In the Create Form Task activity, click the ellipsis (...) to the right of FormData.

  2. 将父下拉列表绑定到工作流。

    在此示例中,创建一个参数,将listOfCountries “列表 <String>”变量作为下拉列表传递到工作流。

    备注:

    listOfCountries变量包含父级下拉列表中的项目,即国家/地区列表。

    1. 将参数命名为CountryList_dropdown 。此参数的“字段键”属性名称为CountryList
    2. “方向”设置为“输入”
    3. 将“类型”设置为System.Collections.Generic.List<System.String>
    4. 将“值” listOfCountries<String>设置为 列表变量。
  3. 将子下拉列表绑定到工作流。

    对于此示例,创建一个参数,用于将stateDictionaryList字典<String,List<String>>变量作为下拉列表传递到工作流。

    备注:

    stateDictionaryList变量包含子下拉列表中的项目,即每个国家/地区的州。

    1. 将参数命名为stateDictList_dropdown 。此参数的“字段键”属性名称为stateDictList
    2. “方向”设置为“输入”
    3. 将“类型”设置为System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.List<System.String>
    4. “值”设置为stateDictionaryList字典<String,列表<String> 变量
  4. 将子下拉列表绑定到父下拉列表。

    Create an argument with the name of the child dropdown and add the _parent suffix. Then set the Value of the argument to the name of the parent dropdown, like this: ”ParentDropdownVariableName”.

    在此示例中,创建一个名为 stateDictList_parent的参数。 子下拉列表为 stateDictList ,您需要向其添加 _parent 后缀。

    1. “方向”设置为“输入”
    2. 将“类型”设置为String
    3. “值”设置为”CountryList”

    When populating the stateDictList Dictionary variable, take note that the dictionary Key is a value from the parent drop-down list and its corresponding Value is a list of options to be shown on the form if the parent is set to the key.

    提示:

    您可以在FormData集合中传递要预填充的值(例如,使用国家/地区和州字段)。如果要传递子值,请确保还添加了父值,以防止意外行为。

  5. Map each value from the parent drop-down to a List of Strings variable. You can populate the list (dictionary) for the parent drop-down in any way, but for this example, we use an Add to Dictionary activity for each value.

    • Dictionary: the dictionary of the child drop-down, stateDictList.
    • Key: a value from the list of strings for the parent drop-down, CountryList - in this example, "US", "India", and "Romania".
    • :按Ctrl + K并输入一个名称,“字符串列表”变量的名称即可保存在父级中选择键值时要在子下拉列表中显示的值 - usaStatesListindianStatesListromanianCountyList 、。
  6. Make sure you place the activity or activities for the above step before the Create Form Task activity.

  7. Click OK to close Form Data.

  8. Open the Variables panel and initialize the new List of String variables you created with the following default values:

    • 对于 indianStatesListnew List(of string) from { "Odisha", "Rajasthan", "Karnataka" }
    • 对于 usaStatesListnew List(of string) from {"Florida", "Georgia", "Washington"}
    • 对于 romanianCountyList: new List(of string) from {"Cluj", "Prahova", "Constanta"}

从此处下载这些示例

在“编辑网格”和“数据网格”组件中创建级联下拉列表

To use cascaded drop-downs inside a Edit Grid or Data Grid component:

  1. Create the drop-down fields following the steps above (using the FormData wizard).

  2. 打开表单设计器。

  3. 如果未在表单中创建下拉字段,请验证:

    • The <dropdownKey> , <dropdownKey>_dropdown, and <dropdownKey>_parent arguments are correctly added in the FormData collection.
    • The GenerateInputFields box is checked.
  4. Drag and drop the Edit Grid or Data Grid component.

  5. Drag and drop the drop-downs created at Step 1 into the Edit Grid or Data Grid component.

  6. 打开子下拉列表的配置菜单(单击 )。

  7. In the Logic tab, notice the preconfigured advanced logic.

    docs image

  8. Navigate to the Actions > Schema Definition field.

  9. 将架构表达式中的 [data.<parent_dropdown_key>] 替换为 [row.<parent_dropdown_key>]

    docs image

    备注:

    row关键字指示表单使用网格行中的父项值。

  10. 保存表单。

设置下拉列表的搜索结果数量

默认情况下,下拉列表最多显示四个搜索结果。 您可以通过在表单设计中设置属性来更改此限制。

To set the number of search results for a drop-down:

  1. In the UiPath Form Designer, click Edit to open settings for the drop-down list and then select the Data tab.
  2. Under Choices.js options, add { "searchResultLimit" : x }, where x is the maximum number of results you want to show.

显示下拉列表中的所有选项

如果下拉菜单中的字符串超过 50 个字符,则系统可能会忽略这些字符。

要显示与您的搜索词匹配的所有选项,请执行以下操作:

  1. 单击“编辑 JSON”docs image要编辑的下拉列表组件的名称。
  2. In the Component JSON field, add the following properties:
    ...
      "fuseOptions": {
        "distance": 800,
        },
      "threshold": 1,
      "useExactSearch": false,
    ...
    ...
      "fuseOptions": {
        "distance": 800,
        },
      "threshold": 1,
      "useExactSearch": false,
    ...
    
备注:

threshold属性指定算法在哪个点停止给定搜索词的搜索操作。例如, 0threshold需要字母和位置精确匹配。1threshold可以匹配任何内容,甚至包括拼写错误。根据您的用例调整threshold值。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新