It is advisable to assign the main table members to all sub-form members

As shown in the figure above, I hope that the selected members above can assign values ​​to the subform below. It stands to reason that formula editing is possible, but it has no effect, so this article uses JS as an example to solve this problem

1. Bind an onchange event to the selection assignment member

2. Click OK directly

 

3. Enter the code 

export function onChange({ value }) {
  const tableField = this.$('tableField_lgx9lkoh');
  const item = this.$('tableField_lgx9lkoh').getItems();
  item.forEach(formGroupId=>{
    tableField.updateItemValue(formGroupId, {employeeField_lh0i7m10:value})
  })
}

The tableField_lgx9lkoh here is the unique identifier of the subform, and employeeField_lh0i7m10 is the unique identifier of the member field in the subform, just replace it when you use it.

Specifically how to look at the following figure:

 

4. Modify BUG

The above code only realizes that when the selected assignment member is selected, it can be assigned to the employee who belongs to the task, but if a sub-form is added, the data of the selected assigned member cannot be synchronized later, so I add an event to the task form and add a new one action

 Then enter the following code

export function onAddClick(newGroupId){
  const chooseValue = this.$('employeeField_lgx9lkof').getValue()
  const tableField = this.$('tableField_lgx9lkoh');
  const item = this.$('tableField_lgx9lkoh').getItems();
  item.forEach(formGroupId => {
    tableField.updateItemValue(formGroupId, { employeeField_lh0i7m10: chooseValue })
  })
}

Similarly, the tableField_lgx9lkoh here is the unique identifier of the subform, and employeeField_lh0i7m10 is the unique identifier of the member field in the subform, just replace it when you use it. 

Guess you like

Origin blog.csdn.net/weixin_55109830/article/details/130439140