我正在为一个工作项目制作自适应卡,并且有一个问题,如何在适当的切换可见性部分下显示四种类型的标签值(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"
]
}
]
},
{
"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
}
]
}
]
}
]
}
答案 0 :(得分:1)
查看您的数据确实有些棘手。
我建议您更改道具的命名方式,以使用不带连字符的驼峰式……很容易。
您必须做一些事情:
尝试使用此模板:
{
"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"
}
查看是否有任何帮助,但可以。