Skip to main content

Gets the value of the subform and assigns it to the current main form.

1. Usage scenarios

When you need to obtain subform values, suchThe list in the current outbound table can be obtained according to the following example.

2. Video Display

Please look forward to it ~

3. Procedure

3.1 Step 1: Create a form

You can add a numeric component and a subform component first; Add a single-line text and a numeric component in the subform and set a default value for the numeric component in the subform.

Form editing page

3.2 Step 2: Open JS panel and write code

JS panel

The following code can be copied directly,Please note the replacement of the unique ID of the form!

const sonform = this.$("子表单的唯一标识").getValue();
const arr = []
console.log(sonform)
sonform.forEach(item => {

arr.push(item.子表单的数值组件唯一标识)
})
this.$("主表中需赋值组件的唯一标识").setValue(JSON.stringify(arr))

3.2.1 obtain the value of the subform

To obtain the values in the subform on the page, you must use JS to obtain the values of all components in the subform by using this.$("unique identifier of the subform").getValue():

3.2.2 get the fields in the subform

At this time, the sonform we get is an array. We need to traverse the array to get the value, as follows:

3.2.3 assign values

At this time, the values we need have been obtained and stored in the new array. We can assign values with setValue().

4. Final effect


-------------------- Get the latest information YIDA, welcome to follow US--------------------

This doc is generated using machine translation. Any discrepancies or differences created in the translation are not binding and have no legal effect for compliance or enforcement purposes.
Copyright © 2024钉钉(中国)信息技术有限公司和/或其关联公司浙ICP备18037475号-4