How to obtain the record ID of the selected item in a dropdown list in google app-maker

╄→гoц情女王★ 提交于 2019-12-24 07:36:19

问题


Summary

Obtaining the record ID of the selected item in a drop-down list or radio-button UI appears to be a common question, but I have not found the answer for Google AppMaker despite months of searching.

The example use case: is I wish to edit a product that belongs to a family:

Product - (N:1) --> Family

Product - (M:N) --> FeatureValues

Example

The product belongs to the family Credit Card.

The credit-card family has the following features: |Contactles |Near field |Rates |Chip & Pin|

In the edit form if I change the family the product belongs to then the list of features will change and new values for the features will need to be entered. (Dynamic form)

Hierarchy table

The family, features and permitted values are held in a single hierarchy table:

Family | Features | Values

newValue._key appears to only work for text-box UI items.

Dropdown list:

widget.datasource.item.Id or _key provides the Product ID of the parent data source, ProductById (because I am editing a single product)

widget.datasource.selectKey(newValue._key); returns undefined

Sample code

Drop-down-list OnValueChange event:

//update the features drop-down based on the taxonomy family selected app.datasources.TaxonomyChildren.query.parameters.parent_fk = app.datasources.TaxonomyFamilies.item.Id;

app.datasources.TaxonomyChildren.load();

If I can pick up the record ID for the selected family in the dropdown list I can set a query.filter.parameter to show the features and values for the newly selected family.

Note: if it is a case you cannot create 'dynamic' forms in Google app-maker, then I'll stop as this has exhausted a lot of time.


回答1:


Markus wrote: So leave the options and value settings but in the onValueEdit run your query against TaxonomyChildren by passing in newValue.id to the query

Great Markus, that worked. On the drop-down ValueEdit event I call the function loadTaxonomyChildById(newValue.Id); passing it the Id of the selected TaxonomyFamily, changing the features displayed.



来源:https://stackoverflow.com/questions/57062051/how-to-obtain-the-record-id-of-the-selected-item-in-a-dropdown-list-in-google-ap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!