关于显示数据的自适应卡片问题
Adaptive cards question on displaying data
我正在为一个工作项目制作一张自适应卡片,我对如何在适当的切换可见性部分下显示 4 种类型的标签值(100 克、每日摄入量、份量、成品重量)有疑问。我能够显示产品信息,但在处理标签值时遇到问题。我已经包含了模板和数据
模板
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Nutritional Approvals",
"id": "Title Text",
"size": "ExtraLarge",
"weight": "Bolder",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"size": "Large",
"weight": "Bolder",
"text": "**APPROVAL**"
}
],
"width": "stretch"
},
{
"type": "Column",
"items": [
{
"type": "Image",
"url": "https://adaptivecards.io/content/pending.png",
"altText": "Pending",
"height": "30px"
}
],
"width": "auto"
}
]
},
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "EXPORT AS PDF",
"url": "https://adaptivecards.io"
}
]
}
]
}
]
}
]
}
],
"bleed": true
},
{
"type": "TextBlock",
"text": "Product Information",
"id": "Product Information",
"horizontalAlignment": "Center",
"size": "Large"
},
{
"type": "Container",
"id": "ProdInfoContainer",
"items": [
{
"$data": "{propertiesProductInformation}",
"type": "FactSet",
"facts": [
{
"title": "Item Number",
"value": "{ItemNumber}"
},
{
"title": "Item Type",
"value": "{ItemType}"
},
{
"title": "Branch Plant",
"value": "{BranchPlant}"
},
{
"title": "Line ID",
"value": "{LineID}"
},
{
"title": "Product Description",
"value": "{ProductDescription}"
},
{
"title": "Stocking Type",
"value": "{StockingType}"
}
],
"id": "ProdInfoFactSet"
}
]
},
{
"type": "TextBlock",
"text": "Nutrition",
"id": "Nutrition Text Block",
"size": "Large",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "100G",
"targetElements": [
"factsethundred"
]
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "Daily Values",
"targetElements": []
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "Finished Piece Weight",
"targetElements": []
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "Serving Size",
"targetElements": []
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ShowCard",
"title": "Reject",
"style": "destructive",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "RejectCommentID",
"placeholder": "Please specify an appropriate reason for rejection.",
"isMultiline": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
数据
{
"propertiesProductInformation": [
{
"ItemNumber": "3022",
"ItemType": "Finished Good",
"BranchPlant": "10100 PLANT",
"LineID": "PN1",
"ProductDescription": "RETAIL",
"StockingType": "S",
"propertiesNutrition": [
{
"Label_Type": "100G",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 160.750,
"New_Value": 160.750,
"Flag": true
},
{
"Nutritional_Desc": "Calories from SatFat",
"JDE_UOM_Description": "Calories",
"Current_Value": 0.651,
"New_Value": 0.651,
"Flag": true
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 4.411,
"New_Value": 4.411,
"Flag": true
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 33.913,
"New_Value": 33.913,
"Flag": true
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.932,
"New_Value": 0.932,
"Flag": true
},
{
"Nutritional_Desc": "Soluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.052,
"New_Value": 0.052,
"Flag": false
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.772,
"New_Value": 0.772,
"Flag": true
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.352,
"New_Value": 0.352,
"Flag": true
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.477,
"New_Value": 0.477,
"Flag": true
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.072,
"New_Value": 0.072,
"Flag": true
},
{
"Nutritional_Desc": "Mono Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.043,
"New_Value": 0.043,
"Flag": true
},
{
"Nutritional_Desc": "Poly Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.236,
"New_Value": 0.236,
"Flag": true
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B1 - Thiamin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.346,
"New_Value": 0.346,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B2 - Riboflavin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.180,
"New_Value": 0.180,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin Equiv",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.777,
"New_Value": 2.777,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.777,
"New_Value": 2.777,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.221,
"New_Value": 0.221,
"Flag": true
},
{
"Nutritional_Desc": "Folate",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 82.963,
"New_Value": 82.963,
"Flag": false
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 7.426,
"New_Value": 7.426,
"Flag": true
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.711,
"New_Value": 2.711,
"Flag": true
},
{
"Nutritional_Desc": "Magnesium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 5.428,
"New_Value": 5.428,
"Flag": false
},
{
"Nutritional_Desc": "Phosphorus",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 21.062,
"New_Value": 21.062,
"Flag": false
},
{
"Nutritional_Desc": "Potassium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 49.537,
"New_Value": 49.537,
"Flag": true
},
{
"Nutritional_Desc": "Sodium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 1.188,
"New_Value": 1.188,
"Flag": true
},
{
"Nutritional_Desc": "Ash",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.126,
"New_Value": 0.126,
"Flag": true
},
{
"Nutritional_Desc": "Calories from Fat",
"JDE_UOM_Description": "Calories",
"Current_Value": 4.291,
"New_Value": 4.291,
"Flag": true
},
{
"Nutritional_Desc": "Folate, DFE",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 127.341,
"New_Value": 127.341,
"Flag": false
},
{
"Nutritional_Desc": "Folate, food",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 19.566,
"New_Value": 19.566,
"Flag": true
},
{
"Nutritional_Desc": "Folic Acid",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 63.397,
"New_Value": 63.397,
"Flag": false
},
{
"Nutritional_Desc": "Gram Weight",
"JDE_UOM_Description": "Grams",
"Current_Value": 64.500,
"New_Value": 64.500,
"Flag": true
},
{
"Nutritional_Desc": "Insoluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.469,
"New_Value": 0.469,
"Flag": false
},
{
"Nutritional_Desc": "Net Carbs",
"JDE_UOM_Description": "Grams",
"Current_Value": 33.913,
"New_Value": 33.913,
"Flag": true
}
]
},
{
"Label_Type": "Daily Values",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
}
]
},
{
"Label_Type": "Finished Piece Weight",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 160.000,
"New_Value": 160.000,
"Flag": true
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 4.000,
"New_Value": 4.000,
"Flag": true
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 34.000,
"New_Value": 34.000,
"Flag": true
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.200,
"New_Value": 0.200,
"Flag": true
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 10.000,
"New_Value": 10.000,
"Flag": true
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.700,
"New_Value": 2.700,
"Flag": true
}
]
},
{
"Label_Type": "Serving Size",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Ash",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.197,
"New_Value": 0.197,
"Flag": true
},
{
"Nutritional_Desc": "Calories from Fat",
"JDE_UOM_Description": "Calories",
"Current_Value": 5.000,
"New_Value": 5.000,
"Flag": true
},
{
"Nutritional_Desc": "Folate, DFE",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 200.000,
"New_Value": 200.000,
"Flag": true
},
{
"Nutritional_Desc": "Folate, food",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 30.785,
"New_Value": 30.785,
"Flag": true
},
{
"Nutritional_Desc": "Folic Acid",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 99.748,
"New_Value": 99.748,
"Flag": true
},
{
"Nutritional_Desc": "Gram Weight",
"JDE_UOM_Description": "Grams",
"Current_Value": 100.000,
"New_Value": 100.000,
"Flag": true
},
{
"Nutritional_Desc": "Insoluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.738,
"New_Value": 0.738,
"Flag": true
},
{
"Nutritional_Desc": "Net Carbs",
"JDE_UOM_Description": "Grams",
"Current_Value": 53.358,
"New_Value": 53.358,
"Flag": true
},
{
"Nutritional_Desc": "Water",
"JDE_UOM_Description": "Grams",
"Current_Value": 38.275,
"New_Value": 38.275,
"Flag": true
},
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 250.000,
"New_Value": 250.000,
"Flag": true
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 7.000,
"New_Value": 7.000,
"Flag": true
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 53.000,
"New_Value": 53.000,
"Flag": true
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Soluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.082,
"New_Value": 0.082,
"Flag": true
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B1 - Thiamin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.500,
"New_Value": 0.500,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B2 - Riboflavin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.300,
"New_Value": 0.300,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin Equiv",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 4.400,
"New_Value": 4.400,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 4.400,
"New_Value": 4.400,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.300,
"New_Value": 0.300,
"Flag": true
},
{
"Nutritional_Desc": "Folate",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 130.000,
"New_Value": 130.000,
"Flag": true
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 10.000,
"New_Value": 10.000,
"Flag": true
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 4.300,
"New_Value": 4.300,
"Flag": true
},
{
"Nutritional_Desc": "Magnesium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 10.000,
"New_Value": 10.000,
"Flag": false
},
{
"Nutritional_Desc": "Phosphorus",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 30.000,
"New_Value": 30.000,
"Flag": false
}
]
}
]
}
]
}
查看了您的数据,确实有点棘手。
我建议更改 props 的命名以使用不带连字符的驼峰式命名...容易得多。
你必须做几件事:
- 在每个类别的切换按钮下方添加一个容器
- 向该容器添加一个事实集,设置 id 并将 id 添加为切换按钮的目标
- 给容器添加一个where条件"where type = 100G"
试试这个模板:
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Nutritional Approvals",
"id": "Title Text",
"size": "ExtraLarge",
"weight": "Bolder",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"size": "Large",
"weight": "Bolder",
"text": "**APPROVAL**"
}
],
"width": "stretch"
},
{
"type": "Column",
"items": [
{
"type": "Image",
"url": "https://adaptivecards.io/content/pending.png",
"altText": "Pending",
"height": "30px"
}
],
"width": "auto"
}
]
},
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "EXPORT AS PDF",
"url": "https://adaptivecards.io"
}
]
}
]
}
]
}
]
}
],
"bleed": true
},
{
"type": "TextBlock",
"text": "Product Information",
"id": "Product Information",
"horizontalAlignment": "Center",
"size": "Large"
},
{
"type": "Container",
"id": "ProdInfoContainer",
"items": [
{
"$data": "{propertiesProductInformation}",
"type": "FactSet",
"facts": [
{
"title": "Item Number",
"value": "{ItemNumber}"
},
{
"title": "Item Type",
"value": "{ItemType}"
},
{
"title": "Branch Plant",
"value": "{BranchPlant}"
},
{
"title": "Line ID",
"value": "{LineID}"
},
{
"title": "Product Description",
"value": "{ProductDescription}"
},
{
"title": "Stocking Type",
"value": "{StockingType}"
}
],
"id": "ProdInfoFactSet"
}
]
},
{
"type": "TextBlock",
"text": "Nutrition",
"id": "Nutrition Text Block",
"size": "Large",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "100G",
"targetElements": [
"factsethundred"
],
"id": ""
}
]
},
{
"type": "Container",
"items": [
{
"type": "FactSet",
"$data": "{propertiesProductInformation[0].propertiesNutrition[0].propertiesNutritionLabelDetails}",
"$when": "{LabelType ='100G'}",
"facts": [
{
"title": "{NutritionalDesc}",
"value": "{NewValue}"
}
],
"id": "factsethundred"
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ShowCard",
"title": "Reject",
"style": "destructive",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "RejectCommentID",
"placeholder": "Please specify an appropriate reason for rejection.",
"isMultiline": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
看看这是否对您有所帮助,但应该如此。
我正在为一个工作项目制作一张自适应卡片,我对如何在适当的切换可见性部分下显示 4 种类型的标签值(100 克、每日摄入量、份量、成品重量)有疑问。我能够显示产品信息,但在处理标签值时遇到问题。我已经包含了模板和数据
模板
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Nutritional Approvals",
"id": "Title Text",
"size": "ExtraLarge",
"weight": "Bolder",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"size": "Large",
"weight": "Bolder",
"text": "**APPROVAL**"
}
],
"width": "stretch"
},
{
"type": "Column",
"items": [
{
"type": "Image",
"url": "https://adaptivecards.io/content/pending.png",
"altText": "Pending",
"height": "30px"
}
],
"width": "auto"
}
]
},
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "EXPORT AS PDF",
"url": "https://adaptivecards.io"
}
]
}
]
}
]
}
]
}
],
"bleed": true
},
{
"type": "TextBlock",
"text": "Product Information",
"id": "Product Information",
"horizontalAlignment": "Center",
"size": "Large"
},
{
"type": "Container",
"id": "ProdInfoContainer",
"items": [
{
"$data": "{propertiesProductInformation}",
"type": "FactSet",
"facts": [
{
"title": "Item Number",
"value": "{ItemNumber}"
},
{
"title": "Item Type",
"value": "{ItemType}"
},
{
"title": "Branch Plant",
"value": "{BranchPlant}"
},
{
"title": "Line ID",
"value": "{LineID}"
},
{
"title": "Product Description",
"value": "{ProductDescription}"
},
{
"title": "Stocking Type",
"value": "{StockingType}"
}
],
"id": "ProdInfoFactSet"
}
]
},
{
"type": "TextBlock",
"text": "Nutrition",
"id": "Nutrition Text Block",
"size": "Large",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "100G",
"targetElements": [
"factsethundred"
]
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "Daily Values",
"targetElements": []
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "Finished Piece Weight",
"targetElements": []
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "Serving Size",
"targetElements": []
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ShowCard",
"title": "Reject",
"style": "destructive",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "RejectCommentID",
"placeholder": "Please specify an appropriate reason for rejection.",
"isMultiline": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
数据
{
"propertiesProductInformation": [
{
"ItemNumber": "3022",
"ItemType": "Finished Good",
"BranchPlant": "10100 PLANT",
"LineID": "PN1",
"ProductDescription": "RETAIL",
"StockingType": "S",
"propertiesNutrition": [
{
"Label_Type": "100G",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 160.750,
"New_Value": 160.750,
"Flag": true
},
{
"Nutritional_Desc": "Calories from SatFat",
"JDE_UOM_Description": "Calories",
"Current_Value": 0.651,
"New_Value": 0.651,
"Flag": true
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 4.411,
"New_Value": 4.411,
"Flag": true
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 33.913,
"New_Value": 33.913,
"Flag": true
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.932,
"New_Value": 0.932,
"Flag": true
},
{
"Nutritional_Desc": "Soluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.052,
"New_Value": 0.052,
"Flag": false
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.772,
"New_Value": 0.772,
"Flag": true
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.352,
"New_Value": 0.352,
"Flag": true
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.477,
"New_Value": 0.477,
"Flag": true
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.072,
"New_Value": 0.072,
"Flag": true
},
{
"Nutritional_Desc": "Mono Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.043,
"New_Value": 0.043,
"Flag": true
},
{
"Nutritional_Desc": "Poly Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.236,
"New_Value": 0.236,
"Flag": true
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B1 - Thiamin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.346,
"New_Value": 0.346,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B2 - Riboflavin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.180,
"New_Value": 0.180,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin Equiv",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.777,
"New_Value": 2.777,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.777,
"New_Value": 2.777,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.221,
"New_Value": 0.221,
"Flag": true
},
{
"Nutritional_Desc": "Folate",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 82.963,
"New_Value": 82.963,
"Flag": false
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 7.426,
"New_Value": 7.426,
"Flag": true
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.711,
"New_Value": 2.711,
"Flag": true
},
{
"Nutritional_Desc": "Magnesium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 5.428,
"New_Value": 5.428,
"Flag": false
},
{
"Nutritional_Desc": "Phosphorus",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 21.062,
"New_Value": 21.062,
"Flag": false
},
{
"Nutritional_Desc": "Potassium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 49.537,
"New_Value": 49.537,
"Flag": true
},
{
"Nutritional_Desc": "Sodium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 1.188,
"New_Value": 1.188,
"Flag": true
},
{
"Nutritional_Desc": "Ash",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.126,
"New_Value": 0.126,
"Flag": true
},
{
"Nutritional_Desc": "Calories from Fat",
"JDE_UOM_Description": "Calories",
"Current_Value": 4.291,
"New_Value": 4.291,
"Flag": true
},
{
"Nutritional_Desc": "Folate, DFE",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 127.341,
"New_Value": 127.341,
"Flag": false
},
{
"Nutritional_Desc": "Folate, food",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 19.566,
"New_Value": 19.566,
"Flag": true
},
{
"Nutritional_Desc": "Folic Acid",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 63.397,
"New_Value": 63.397,
"Flag": false
},
{
"Nutritional_Desc": "Gram Weight",
"JDE_UOM_Description": "Grams",
"Current_Value": 64.500,
"New_Value": 64.500,
"Flag": true
},
{
"Nutritional_Desc": "Insoluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.469,
"New_Value": 0.469,
"Flag": false
},
{
"Nutritional_Desc": "Net Carbs",
"JDE_UOM_Description": "Grams",
"Current_Value": 33.913,
"New_Value": 33.913,
"Flag": true
}
]
},
{
"Label_Type": "Daily Values",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
}
]
},
{
"Label_Type": "Finished Piece Weight",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 160.000,
"New_Value": 160.000,
"Flag": true
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 4.000,
"New_Value": 4.000,
"Flag": true
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 34.000,
"New_Value": 34.000,
"Flag": true
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.200,
"New_Value": 0.200,
"Flag": true
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 10.000,
"New_Value": 10.000,
"Flag": true
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 2.700,
"New_Value": 2.700,
"Flag": true
}
]
},
{
"Label_Type": "Serving Size",
"propertiesNutrition_Label_Details": [
{
"Nutritional_Desc": "Ash",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.197,
"New_Value": 0.197,
"Flag": true
},
{
"Nutritional_Desc": "Calories from Fat",
"JDE_UOM_Description": "Calories",
"Current_Value": 5.000,
"New_Value": 5.000,
"Flag": true
},
{
"Nutritional_Desc": "Folate, DFE",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 200.000,
"New_Value": 200.000,
"Flag": true
},
{
"Nutritional_Desc": "Folate, food",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 30.785,
"New_Value": 30.785,
"Flag": true
},
{
"Nutritional_Desc": "Folic Acid",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 99.748,
"New_Value": 99.748,
"Flag": true
},
{
"Nutritional_Desc": "Gram Weight",
"JDE_UOM_Description": "Grams",
"Current_Value": 100.000,
"New_Value": 100.000,
"Flag": true
},
{
"Nutritional_Desc": "Insoluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.738,
"New_Value": 0.738,
"Flag": true
},
{
"Nutritional_Desc": "Net Carbs",
"JDE_UOM_Description": "Grams",
"Current_Value": 53.358,
"New_Value": 53.358,
"Flag": true
},
{
"Nutritional_Desc": "Water",
"JDE_UOM_Description": "Grams",
"Current_Value": 38.275,
"New_Value": 38.275,
"Flag": true
},
{
"Nutritional_Desc": "Calories",
"JDE_UOM_Description": "Calories",
"Current_Value": 250.000,
"New_Value": 250.000,
"Flag": true
},
{
"Nutritional_Desc": "Protein",
"JDE_UOM_Description": "Grams",
"Current_Value": 7.000,
"New_Value": 7.000,
"Flag": true
},
{
"Nutritional_Desc": "Carbohydrates",
"JDE_UOM_Description": "Grams",
"Current_Value": 53.000,
"New_Value": 53.000,
"Flag": true
},
{
"Nutritional_Desc": "Dietary Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Soluble Fiber (2016)",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.082,
"New_Value": 0.082,
"Flag": true
},
{
"Nutritional_Desc": "Total Sugars",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Added Sugar",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 1.000,
"New_Value": 1.000,
"Flag": true
},
{
"Nutritional_Desc": "Saturated Fat",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": true
},
{
"Nutritional_Desc": "Trans Fatty Acid",
"JDE_UOM_Description": "Grams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Cholesterol",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.000,
"New_Value": 0.000,
"Flag": false
},
{
"Nutritional_Desc": "Vitamin B1 - Thiamin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.500,
"New_Value": 0.500,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B2 - Riboflavin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 0.300,
"New_Value": 0.300,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin Equiv",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 4.400,
"New_Value": 4.400,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin B3 - Niacin",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 4.400,
"New_Value": 4.400,
"Flag": true
},
{
"Nutritional_Desc": "Vitamin D - mcg",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 0.300,
"New_Value": 0.300,
"Flag": true
},
{
"Nutritional_Desc": "Folate",
"JDE_UOM_Description": "Micrograms",
"Current_Value": 130.000,
"New_Value": 130.000,
"Flag": true
},
{
"Nutritional_Desc": "Calcium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 10.000,
"New_Value": 10.000,
"Flag": true
},
{
"Nutritional_Desc": "Iron",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 4.300,
"New_Value": 4.300,
"Flag": true
},
{
"Nutritional_Desc": "Magnesium",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 10.000,
"New_Value": 10.000,
"Flag": false
},
{
"Nutritional_Desc": "Phosphorus",
"JDE_UOM_Description": "Milligrams",
"Current_Value": 30.000,
"New_Value": 30.000,
"Flag": false
}
]
}
]
}
]
}
查看了您的数据,确实有点棘手。
我建议更改 props 的命名以使用不带连字符的驼峰式命名...容易得多。
你必须做几件事:
- 在每个类别的切换按钮下方添加一个容器
- 向该容器添加一个事实集,设置 id 并将 id 添加为切换按钮的目标
- 给容器添加一个where条件"where type = 100G"
试试这个模板:
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Nutritional Approvals",
"id": "Title Text",
"size": "ExtraLarge",
"weight": "Bolder",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"style": "emphasis",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"size": "Large",
"weight": "Bolder",
"text": "**APPROVAL**"
}
],
"width": "stretch"
},
{
"type": "Column",
"items": [
{
"type": "Image",
"url": "https://adaptivecards.io/content/pending.png",
"altText": "Pending",
"height": "30px"
}
],
"width": "auto"
}
]
},
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "EXPORT AS PDF",
"url": "https://adaptivecards.io"
}
]
}
]
}
]
}
]
}
],
"bleed": true
},
{
"type": "TextBlock",
"text": "Product Information",
"id": "Product Information",
"horizontalAlignment": "Center",
"size": "Large"
},
{
"type": "Container",
"id": "ProdInfoContainer",
"items": [
{
"$data": "{propertiesProductInformation}",
"type": "FactSet",
"facts": [
{
"title": "Item Number",
"value": "{ItemNumber}"
},
{
"title": "Item Type",
"value": "{ItemType}"
},
{
"title": "Branch Plant",
"value": "{BranchPlant}"
},
{
"title": "Line ID",
"value": "{LineID}"
},
{
"title": "Product Description",
"value": "{ProductDescription}"
},
{
"title": "Stocking Type",
"value": "{StockingType}"
}
],
"id": "ProdInfoFactSet"
}
]
},
{
"type": "TextBlock",
"text": "Nutrition",
"id": "Nutrition Text Block",
"size": "Large",
"horizontalAlignment": "Center"
},
{
"type": "Container",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "100G",
"targetElements": [
"factsethundred"
],
"id": ""
}
]
},
{
"type": "Container",
"items": [
{
"type": "FactSet",
"$data": "{propertiesProductInformation[0].propertiesNutrition[0].propertiesNutritionLabelDetails}",
"$when": "{LabelType ='100G'}",
"facts": [
{
"title": "{NutritionalDesc}",
"value": "{NewValue}"
}
],
"id": "factsethundred"
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ShowCard",
"title": "Reject",
"style": "destructive",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "RejectCommentID",
"placeholder": "Please specify an appropriate reason for rejection.",
"isMultiline": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
看看这是否对您有所帮助,但应该如此。