简体   繁体   中英

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

We are using Aurachain for some of our custom apps. 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 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.

//Get the values from the existing catalog named “City” let catalog = this.getCatalogValues(“”);

//Get the value for “Country” field, completetd in a previws step 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);

We are also using Aurachain platform for our custom apps.

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) .

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. So update this line like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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