Forum Discussion

sowmyaseetha's avatar
sowmyaseetha
Copper Contributor
Sep 27, 2023
Solved

Table in adaptive cards

 

This is my data for table  where the buckets in billingproviderskick will be having many no of objects so , i want to implement this in a table , then i have tried in this as provided in the below code

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Table",
            "columns": [
                {
                    "width": 1
                },
                {
                    "width": 1
                }
        
            ],
            "$data": "${billingProvidersKick.buckets}",
            "rows": [
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "${val}",
                                    "spacing": "Small"
                                },
                                {
                                    "type": "ColumnSet",
                                    "columns": [
                                        {
                                            "type": "Column",
                                            "items": [
                                                {
                                                    "type": "Image",
                                                    "url": "https://cdn-icons-png.flaticon.com/512/49/49172.png",
                                                    "size": "Small"
                                                }
                                            ],
                                            "width": "20px"
                                        },
                                        {
                                            "type": "Column",
                                            "items": [
                                                {
                                                    "type": "TextBlock",
                                                    "weight": "Bolder",
                                                    "text": "$${formatNumber(totalBilledAmount, 10)}",
                                                    "wrap": true
                                                }
                                            ],
                                            "width": "stretch"
                                        }
                                    ]
                                },
                                {
                                    "type": "ColumnSet",
                                    "columns": [
                                        {
                                            "type": "Column",
                                            "items": [
                                                {
                                                    "type": "Image",
                                                    "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAulBMVEX//////v+TlZv///w9R1g/Rlo4P1UzPE+vsbgyOk7v8vQ+RVa0tbv6/f1BSFgtN0lscH0pL0XCw8YwNk3Nz9F6f4cyPEjc3d/39/dfZXHu7vM5P1ErMkZKUGDi4+fS0tdOWGZIT2FSVmducn8oMUJHTFfw9fSjpquYnqIsNEA7O1Clpa0ZIj0aJj4yOlSrsbUnKEFgYXJNSV1WXW+KiJEjLjvi5+ZARl99gI9zeH5rcXlSVl5dXmY+RU6/tsNIAAAGdElEQVR4nO2ci3qiOABGk4ZAAQGtbUXBC63aut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8u/88FIIxAXSwIAAAAASUVORK5CYII=",
                                                    "size": "Small"
                                                }
                                            ],
                                            "width": "20px"
                                        },
                                        {
                                            "type": "Column",
                                            "items": [
                                                {
                                                    "type": "TextBlock",
                                                    "weight": "Bolder",
                                                    "text": "${formatNumber(distinctClaimCount, 0)}",
                                                    "wrap": true
                                                }
                                            ],
                                            "width": "stretch"
                                        }
                                    ]
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "$${formatNumber(totalPaidAmount, 2)}",
                                    "spacing": "Small",
                                    "wrap": true
                                }
                            ]
                        },
                        {
                            "type": "TableCell",
                            "items": [
                                {
                                    "type": "ColumnSet",
                                    "columns": [
                                        {
                                            "type": "Column",
                                            "items": [
                                                {
                                                    "type": "Image",
                                                    "url": "https://media.istockphoto.com/id/613529262/vector/glass-sphere-with-blood.jpg?s=612x612&w=0&k=20&c=JLKQlDcKkiByAr7GEaIqKUutYnfMIat60BJ4WOdVWrY=",
                                                    "altText": "${status}",
                                                    "height": "20px"
                                                }
                                            ],
                                            "width": "auto"
                                        },
                                        {
                                            "type": "Column",
                                            "spacing": "small",
                                            "selectAction": {
                                                "type": "Action.ToggleVisibility",
                                                "title": "expand",
                                                "targetElements": [
                                                    "cardContent${$index}",
                                                    "chevronDown${$index}",
                                                    "chevronUp${$index}"
                                                ]
                                            },
                                            "verticalContentAlignment": "center",
                                            "items": [
                                                {
                                                    "type": "Image",
                                                    "id": "chevronDown${$index}",
                                                    "url": "https://adaptivecards.io/content/down.png",
                                                    "width": "20px"
                                                },
                                                {
                                                    "type": "Image",
                                                    "id": "chevronUp${$index}",
                                                    "url": "https://adaptivecards.io/content/up.png",
                                                    "width": "20px",
                                                    "isVisible": false
                                                }
                                            ],
                                            "width": "auto"
                                        }
                                    ]
                                },
                                {
                                    "type": "Container",
                                    "id": "cardContent${$index}",
                                    "isVisible": false,
                                    "items": [
                                        {
                                            "type": "Container",
                                            "items": [
                                                {
                                                    "$data": "${a_claims.buckets}",
                                                    "type": "TextBlock",
                                                    "text": "* ${val}",
                                                    "isSubtle": false,
                                                    "wrap": true
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                        
                    ]
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5"
}
{
    "billingProvidersKick": {
      "buckets": [
        {
          "val": "normal school",
          "count": 20,
          "totalBilledAmount": 87687.765768,
          "distinctClaimCount": 2,
          "totalPaidAmount": 9058.71,
          "a_claims": {
            "buckets": [
              {
                "val": "1234567",
                "count": 29
              },
              {
                "val": "2345678",
                "count": 20
              }
            ]
          }
         }
       ]
     }
}

 

 

 

here , for each object in bucket the table has been repeated but i wan to repeat the row .
if i add any row as header then this header is attached to every single row 

so please guide me as i want to loop row no the table

  • sowmyaseetha - 

    To repeat the rows instead, you should set the "$data" property at the TableRow level. 

    {
        "type": "AdaptiveCard",
        "body": [
            {
                "type": "Table",
                "columns": [
                    {
                        "width": 1
                    },
                    {
                        "width": 1
                    }
                ],
                "rows": [
                    {
                        "$data": "${billingProvidersKick.buckets}",
                        "type": "TableRow",
                        "cells": [
                            {
                                "type": "TableCell",
                                "items": [
                                    {
                                        "type": "TextBlock",
                                        "text": "${val}",
                                        "spacing": "Small"
                                    },
                                    // ... rest of your code
                                ]
                            },
                            // ... rest of your code
                        ]
                    }
                ]
            }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.5"
    }
    

    In this JSON, the "$data" property is set at the TableRow level, which means that for each object in the "buckets" array, a new row will be created in the table.

     

     

     

    Thanks, 

    Prasad Das

    ------------------------------------------------------------------------------------------ 

    If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link.

1 Reply

  • sowmyaseetha - 

    To repeat the rows instead, you should set the "$data" property at the TableRow level. 

    {
        "type": "AdaptiveCard",
        "body": [
            {
                "type": "Table",
                "columns": [
                    {
                        "width": 1
                    },
                    {
                        "width": 1
                    }
                ],
                "rows": [
                    {
                        "$data": "${billingProvidersKick.buckets}",
                        "type": "TableRow",
                        "cells": [
                            {
                                "type": "TableCell",
                                "items": [
                                    {
                                        "type": "TextBlock",
                                        "text": "${val}",
                                        "spacing": "Small"
                                    },
                                    // ... rest of your code
                                ]
                            },
                            // ... rest of your code
                        ]
                    }
                ]
            }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.5"
    }
    

    In this JSON, the "$data" property is set at the TableRow level, which means that for each object in the "buckets" array, a new row will be created in the table.

     

     

     

    Thanks, 

    Prasad Das

    ------------------------------------------------------------------------------------------ 

    If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link.

Resources