简体   繁体   English

如何在 Aurachain 中使用自定义脚本过滤下拉列表选项?

[英]How can I filter drop-down list options by using custom scripts in Aurachain?

We are using Aurachain for some of our custom apps.我们正在为我们的一些自定义应用程序使用Aurachain And in one of these we have a user interface with a field with drop-down list which takes its values from a city and coutries catalog, and we need it to filter the values returned based on the value from another field.在其中一个中,我们有一个用户界面,其中有一个带有下拉列表的字段,它从城市和国家目录中获取值,我们需要它根据另一个字段的值过滤返回的值。 To be more specific, I want to have a field automatically filled with the country corresponding to the city I select from the drop-down filed.更具体地说,我希望有一个字段自动填充与下拉列表中的城市 I select 对应的国家/地区。

I tried to add a custom code below in the drop-down under the ““onInit" event, and i got the error Cannot read property of indexOf” displayed in console.我尝试在“onInit”事件下的下拉列表中添加自定义代码,但我在控制台中收到错误“无法读取 indexOf 的属性”。

//Get the values from the existing catalog named “City” let catalog = this.getCatalogValues(“”); //从名为“City”的现有目录中获取值 let catalog = this.getCatalogValues(“”);

//Get the value for “Country” field, completetd in a previws step let otherField = this.getValue(“”); //获取“Country”字段的值,在前面的步骤中完成 let otherField = this.getValue(“”);

// Populate the DDL with the catalog rows where value from “otherField” exist 1 time.this.setValues(“”, catalog, row => row.country.indexOf(“otherField”) ==0); // 使用来自“otherField”的值存在的目录行填充 DDL 1 time.this.setValues(“”, catalog, row => row.country.indexOf(“otherField”) ==0);

We are also using Aurachain platform for our custom apps.我们还为我们的自定义应用程序使用 Aurachain 平台。

Check if the column name used in the code is exactly as defined in the catalog (Country or country).检查代码中使用的列名称是否与目录中定义的完全相同(国家或国家)。 Eg row.Country.indexOf("otherField") ==0) or row.country.indexOf("otherField") ==0) .例如row.Country.indexOf("otherField") ==0)row.country.indexOf("otherField") ==0)

Also for the script to work as expected, you will have to make sure that the drop-down property Sort order is set to none in the UI builder.此外,为了使脚本按预期工作,您必须确保在 UI 构建器中将下拉属性排序顺序设置为无。 So update this line like this:所以像这样更新这一行:

//Get the values from the existing catalog named “City”
let catalog = this.getCatalogValues("", {order: "desc", by: "code" });

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM