amis icon indicating copy to clipboard operation
amis copied to clipboard

如何通过按钮单独设置combo中某个item中的字段值?

Open tangjion opened this issue 4 years ago • 7 comments

1.2.2版本中,如何通过按钮单独设置combo中某个item中的字段值?请指教

tangjion avatar Jul 07 '22 02:07 tangjion

没有懂你的意思

qsy1403813547 avatar Jul 07 '22 06:07 qsy1403813547

因为combo是一个对象数组,如果需要设置值,现在只能给combo的name字段设置为一个对象数组的值,无法单个设置,比如我想设置combo中第二个item中的某个字段值其他不变,不知道怎么设置,我尝试使用target来做,但不成功

tangjion avatar Jul 07 '22 07:07 tangjion

image 你说的是这样么

qsy1403813547 avatar Jul 07 '22 07:07 qsy1403813547

image 不知道你是不是这个意思

qsy1403813547 avatar Jul 07 '22 07:07 qsy1403813547

@tangjion

qsy1403813547 avatar Jul 07 '22 07:07 qsy1403813547

所以没有后续了》????????????????????

qsy1403813547 avatar Jul 09 '22 03:07 qsy1403813547

你可以通过指定索引来控制更新哪条数据,通过index来指定,例如:

{
  "type": "page",
  "body": [
    {
      "type": "button",
      "label": "更新数据",
      "onEvent": {
        "click": {
          "actions": [
            {
              "componentId": "combo01",
              "args": {
                "value": {
                  "age": 18,
                  "name": "amis"
                },
                "index": 1
              },
              "actionType": "setValue"
            }
          ],
          "weight": 0
        }
      }
    },
    {
      "type": "form",
      "debug": true,
      "api": "/api/mock2/form/saveForm",
      "body": [
        {
          "type": "combo",
          "name": "user",
          "label": "用户",
          "items": [
            {
              "name": "name",
              "label": "名字",
              "type": "input-text"
            },
            {
              "name": "age",
              "label": "年龄",
              "type": "input-text"
            }
          ],
          "id": "combo01",
          "multiLine": false,
          "multiple": true,
          "joinValues": true
        }
      ],
      "id": "u:43ef458d9691"
    }
  ],
  "id": "u:40855666ec27"
}

hsm-lv avatar Nov 01 '22 12:11 hsm-lv