简体   繁体   English

适当的自适应卡片 Input.ChoiceSet 模板结构

[英]Proper Adaptive Card Input.ChoiceSet Templating Structure

What does the data json need to be to set a choice as selected on an Input.ChoiceSet?要在 Input.ChoiceSet 上选择一个选项,数据 json 需要是什么?

Card Json卡森

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Input.ChoiceSet",
            "placeholder": "Placeholder text",
            "choices": [
                {
                    "title": "Choice 1",
                    "value": "1"
                },
                {
                    "title": "Choice 2",
                    "value": "2"
                }
            ],
            "style": "expanded",
            "id": "sample"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.0"
}

Sample Data Json示例数据 Json

What should the structure of this be if I wanted to set the value of Choice 1 to selected?如果我想将Choice 1的值设置为selected,它的结构应该是什么?

{
    // I've tried this:
    "sample": {
        "value": "1"
    }
}
-----------------------------
{
    // Also tried
    "sample": "1"
}

I'm reading the Adaptive Card schema for Input.ChoiceSet and I see that the card json "value": property can be set in the card for default values, but I'm hoping there is a way to do this from the template json.我正在阅读Input.ChoiceSet自适应卡片架构,我看到卡片 json "value":属性可以在卡片中设置为默认值,但我希望有一种方法可以从模板 json 中做到这一点. Otherwise, I'll have to "inject" it into the card json before I build the card.否则,我必须在构建卡片之前将其“注入”到卡片 json 中。

based on your sample there you have to do this:根据您的样本,您必须执行以下操作:

            [...]
            "placeholder": "Placeholder text",
            "value": 1,
            "choices": [
                {
                    "title": "Choice 1",
                    "value": "1"
                },
             [...]

To set the initial value, based on one of the values in your choices array.根据选择数组中的值之一设置初始值。 It only works if the corresponding value is exactly the same for one of the entries.只有当其中一个条目的相应值完全相同时,它才有效。 There is nothing like "selected: true" or similar if that's what you're asking for.如果这就是您所要求的,则没有像“selected:true”或类似的东西。

When using templating for that, you would have to have a selected property returned and set it as "value": {$root.selected}为此使用模板时,您必须返回一个选定的属性并将其设置为“值”:{$root.selected}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM