我正在尝试在 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"
}
]
}
最佳答案
您可以将容器放置在列中。 此示例可以在列内无错误地显示操作: 在此 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"
}
}]
}
关于c# - 自适应卡片 C# - 如何在 Body ColumnSet(每行)中添加 Action.Submit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50612835/