【问题标题】:Adaptive Cards C# - How to add Action.Submit within the Body ColumnSet (Each Row)自适应卡片 C# - 如何在正文列集中添加 Action.Submit(每行)
【发布时间】:2018-11-09 18:57:46
【问题描述】:

我正在尝试在 BOT DirectLine 聊天中显示自适应卡片。自适应卡将包含表格格式的数据。我想在表格的每一行上添加操作按钮来执行特定的操作。

但我无法在 ColumnSet 中添加“Action.Submit”。我只能在正文部分之外添加(即单独的操作部分)。

请帮助我。下面是发送到 Directline 客户端的示例 JSON。

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.0",
  "body": [
    {
      "type": "Container",
      "items": [
        {
          "type": "TextBlock",
          "text": "Pending Items",
          "weight": "bolder",
          "size": "medium"
        },
        {
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Number",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Module",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Pending count",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Action",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            }
          ]
        },
        {
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Module 1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "Input.Toggle",
                  "id": "acceptTerms",
                  "title": "Select this",
                  "value": "true",
                  "valueOn": "true",
                  "valueOff": "false"
                }
              ]
            }
          ]
        },
        {
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "2",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Module 1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "10",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "Input.Toggle",
                  "id": "acceptTerms",
                  "title": "Select this",
                  "value": "true",
                  "valueOn": "true",
                  "valueOff": "false"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.ShowCard",
      "title": "Proceed Selected",
      "card": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "text": "Are you sure want to Proceed",
            "weight": "bolder",
            "wrap": true
          }
        ],
        "actions": [
          {
            "type": "Action.Submit",
            "title": "OK"
          }
        ]
      }
    },
    {
      "type": "Action.Submit",
      "title": "Cancel",
      "id": "c1"
    }
  ]
}

【问题讨论】:

    标签: c# bots


    【解决方案1】:

    您可以将容器放置在列中。 此示例可以无错误地显示列内的操作: 在这个Adaptive Card Designer进行测试

    {
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.0",
        "body":[
    
                {
                    "type": "TextBlock",
                    "size": "Small",
                    "text": "You have the following Time Off planned:"
                }, {
                    "type": "ColumnSet",
                    "columns": [{
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "Holiday"
                        }]
                    }, {
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "-"
                        }]
                    }, {
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "Approved"
                        }]
                    }, {
                        "type": "Column",
                        "width": "stretch",
                        "items": [{
                            "type": "Container",
                            "items": [{
                                "type": "ActionSet",
                                "actions": [{
                                    "type": "Action.Submit",
                                    "title": "Cancel",
                                    "data": {
                                        "action": "cancelRequest"
                                    }
                                }]
                            }]
                        }]
                    }]
                }, {
                    "type": "ColumnSet",
                    "columns": [{
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "from "
                        }]
                    }, {
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "2019-09-11"
                        }]
                    }, {
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "to "
                        }]
                    }, {
                        "type": "Column",
                        "width": "auto",
                        "items": [{
                            "type": "TextBlock",
                            "size": "Small",
                            "text": "2019-09-18"
                        }]
                    }]
                }],
                "actions": [{
                    "type": "Action.Submit",
                    "title": "Submit New Request",
                    "data": {
                        "action": "timeoff.request.card"
                    }
                }, {
                    "type": "Action.Submit",
                    "title": "Dismiss",
                    "data": {
                        "action": "timeoff.cancel"
                    }
                }]
            }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-10
      • 2019-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-29
      • 2021-08-09
      • 1970-01-01
      相关资源
      最近更新 更多