在制作表格时,自适应卡不显示所有键和值



我最近不得不学习工作中应用程序的自适应卡,并希望表示一个表。我遇到的问题是,当我将示例数据置于预览模式时,它的所有键和值都没有显示在设计器网站上。我已经研究了一段时间,找不到任何语法错误。我想知道我是否有太多的列无法正确渲染,但我不确定。

卡片模板:

{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "100G",
"id": "100Gtxt",
"horizontalAlignment": "Center",
"weight": "Bolder"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "FPW",
"weight": "Bolder",
"id": "FPWtxt",
"horizontalAlignment": "Center"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Serving Size",
"id": "ServingSizetxt",
"horizontalAlignment": "Center",
"weight": "Bolder"
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNutritional}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NutritionalFact",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesUom}",
"title": "{key}",
"value": "{value}"
}
],
"id": "UomFact",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesCurrent1}",
"title": "{key}",
"value": "{value}"
}
],
"id": "CurrentFact1",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNew1}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NewFact1",
"spacing": "None",
"separator": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesCurrent2}",
"title": "{key}",
"value": "{value}"
}
],
"id": "CurrentFact2",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNew2}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NewFact2",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesCurrent3}",
"title": "{key}",
"value": "{value}"
}
],
"id": "CurrentFact3",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNew3}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NewFact3",
"spacing": "None",
"separator": true
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}

样本数据:

{
"propertiesNutritional": [
{
"key": "Nutritional",
"value": "Calories"
}
],
"propertiesUom": [
{
"key": "UOM",
"value": "Calories"
}
],
"propertiesCurrent1": [
{
"key": "Current",
"value": "Number"
}
],
"propertiesNew1": [
{
"key": "New",
"value": "Number"
}
],
"propertiesCurrent2": [
{
"key": "Current",
"value": "Number"
}
],
"propertiesNew2": [
{
"key": "New",
"value": "Number"
}
],
"propertiesCurrent3": [
{
"key": "Current",
"value": "Number"
}
],
"propertiesNew3": [
{
"key": "New",
"value": "Number"
}
]
}

是的,无论出于什么原因(认为它已经被添加为一个问题(,您的属性名称中都不能有数字。例如,将属性Current3更改为属性CurrentC就可以了。

试试这个:

{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "100G",
"id": "100Gtxt",
"horizontalAlignment": "Center",
"weight": "Bolder"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "FPW",
"weight": "Bolder",
"id": "FPWtxt",
"horizontalAlignment": "Center"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Serving Size",
"id": "ServingSizetxt",
"horizontalAlignment": "Center",
"weight": "Bolder"
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNutritional}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NutritionalFact",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesUom}",
"title": "{key}",
"value": "{value}"
}
],
"id": "UomFact",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesCurrentA}",
"title": "{key}",
"value": "{value}"
}
],
"id": "CurrentFact1",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNewA}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NewFact1",
"spacing": "None",
"separator": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesCurrentB}",
"title": "{key}",
"value": "{value}"
}
],
"id": "CurrentFact2",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNewB}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NewFact2",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesCurrentC}",
"title": "{key}",
"value": "{value}"
}
],
"id": "CurrentFact3",
"separator": true,
"spacing": "None"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{propertiesNewC}",
"title": "{key}",
"value": "{value}"
}
],
"id": "NewFact3",
"spacing": "None",
"separator": true
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"

}

这是你的数据:

{
"propertiesNutritional": [{
"key": "Nutritional",
"value": "Calories"
}],
"propertiesUom": [{
"key": "UOM",
"value": "Calories"
}],
"propertiesCurrentA": [{
"key": "Current",
"value": "Number"
}],
"propertiesNewA": [{
"key": "New",
"value": "Number"
}],
"propertiesCurrentB": [{
"key": "Current",
"value": "Number"
}],
"propertiesNewB": [{
"key": "New",
"value": "Number"
}],
"propertiesCurrentC": [{
"key": "Current",
"value": "Number"
}],
"propertiesNewC": [{
"key": "New",
"value": "Number"
}]
}

最新更新