Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

表单里的表格,只提交选中的行记录,怎么实现? #11115

Open
wanquantong opened this issue Oct 26, 2024 · 2 comments
Open

表单里的表格,只提交选中的行记录,怎么实现? #11115

wanquantong opened this issue Oct 26, 2024 · 2 comments
Labels

Comments

@wanquantong
Copy link

实现场景:

表单,里面是表格,可以勾选行。
我只想将选中的记录提交到接口,怎么实现?

{
  "type": "form",
  "id": "u:3356cf723f58",
  "title": "表单-发送选中的记录",
  "mode": "flex",
  "labelAlign": "top",
  "dsType": "api",
  "feat": "Edit",
  "body": [
    {
      "type": "table2",
      "source": "$rows",
      "selectable": true,
      "onEvent": {
        "selectedChange": {
          "actions": [
            {
              "actionType": "toast",
              "args": {
                "msg": "已选择${event.data.selectedItems.length}条记录"
              }
            }
          ]
        }
      },
      "columns": [
        {
          "name": "id",
          "label": "ID",
          "id": "u:25486bbd6839",
          "placeholder": "-"
        },
        {
          "name": "engine",
          "label": "Rendering engine",
          "id": "u:7b89763d129f",
          "placeholder": "-"
        },
        {
          "name": "browser",
          "label": "Browser",
          "id": "u:bfb75d897ba7",
          "placeholder": "-"
        },
        {
          "name": "platform",
          "label": "Platform(s)",
          "id": "u:21528b8b0300"
        },
        {
          "name": "version",
          "label": "Engine version",
          "id": "u:1d10d2bac22a"
        },
        {
          "name": "grade",
          "label": "CSS grade",
          "id": "u:e6498f2140d0"
        }
      ],
      "id": "u:bf0752d28a1b",
      "showHeader": true,
      "editorSetting": {
        "mock": {
          "enable": true,
          "maxDisplayRows": 5
        }
      }
    }
  ],
  "actions": [
    {
      "type": "button",
      "label": "发送选中的记录",
      "onEvent": {
        "click": {
          "actions": [
            {
              "actionType": "submit",
              "componentId": "u:3356cf723f58"
            },
            {
              "ignoreError": false,
              "actionType": "toast",
              "args": {
                "msgType": "info",
                "position": "top-right",
                "closeButton": true,
                "showIcon": true,
                "msg": "GETRENDERERDATA(id, path)",
                "className": "theme-toast-action-scope"
              }
            }
          ]
        }
      },
      "level": "primary",
      "id": "u:b5f6cda8c4be"
    }
  ],
  "resetAfterSubmit": true,
  "initApi": "https://aisuda.bce.baidu.com/amis/api/mock2/sample?perPage=10"
}
@github-actions github-actions bot added the feat label Oct 26, 2024
Copy link

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@lhtuling
Copy link

自定义js 进阶用法了
获取选中的行

event.context.scoped.getComponentById("u:bf0752d28a1b").getData().selectedItems

然后用ajax的动作执行api请求,不要用表单提交了

Amis低代码前端框架交流群【QQ 1群】:717791727
Amis低代码前端框架交流群【QQ 2群】:721182449

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants