2017-09-12 4 views
4

Comment puis-je ajouter des actions pour les conteneurs? Selon le documentation Le type de conteneur a un objet "actions", mais lors du test de la carte dans le adaptive cards visualizer ou dans l'émulateur bot-framework, aucun bouton n'est affiché. Ci-joint un exemple du type de carte que j'essaie de générer.Cartes Adaptive BotFramework - Les actions du conteneur ne sont pas rendues

Merci pour votre aide.

{ 
    "type": "AdaptiveCard", 
    "body": [ 
    { 

     "style":"normal", 
     "type": "Container", 
     "separation" : "strong", 
     "actions": [ 
      { 
       "type": "Action.OpenUrl", 
       "url": "http://foo.bar.com", 
       "title": "adaptivecards1" 
      } 
      ], 
     "items": [ 
      { 
       "type": "ColumnSet", 
       "separation": "strong", 
       "columns": [ 
        { 
         "type": "Column", 
         "size":1, 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": "Title", 
           "size": "large", 
           "isSubtle": true 
          }, 
          { 
           "type": "TextBlock", 
           "text": "Model: ABC", 
           "size": "small" 
          } 
         ] 
        }, 
        { 
         "type": "Column", 
         "size": "1", 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": " " 
          }, 
          { 
           "type": "Image", 
           "url": "https://path/to/image.jpg", 
           "size": "large", 
           "horizontalAlignment" :"right" 
          } 
         ] 
        } 
       ] 
      } 
     ] 
    }, 
    { 

     "style":"normal", 
     "type": "Container", 
     "separation" : "strong", 
     "actions": [ 
      { 
       "type": "Action. OpenUrl", 
       "url": "http://foo.bar.com", 
       "title": "adaptivecards2" 
      } 
      ], 
     "items": [ 
      { 
       "type": "ColumnSet", 
       "separation": "strong", 
       "columns": [ 
        { 
         "type": "Column", 
         "size":1, 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": "Another Title", 
           "size": "large", 
           "isSubtle": true 
          }, 
          { 
           "type": "TextBlock", 
           "text": "Model: XYZ", 
           "size": "small" 
          }       ] 
        }, 
        { 
         "type": "Column", 
         "size": "1", 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": " " 
          }, 
          { 
           "type": "Image", 
           "url": "https://path/to/other/image.jpg", 
           "size": "large", 
           "horizontalAlignment" :"right" 
          } 
         ] 
        } 
       ] 
      } 
     ] 
    } 
]} 
+0

Malheureusement, c'est un bug dans nos documents, les conteneurs n'ont pas d'actions actuellement. C'est quelque chose que nous prévoyons de visiter à l'avenir, mais aucun plan concret pour le moment. Les documents seront mis à jour prochainement –

Répondre

1

Par cette GitHub issue, il semble qu'il y ait une erreur dans la documentation et que la propriété actions n'existe pas sur Container. Au lieu de cela, vous devez ajouter un élément de type ActionSet à votre tableau items, avec la liste actions.

Après votre échantillon, il devrait ressembler à:

{ 
    "type": "AdaptiveCard", 
    "body": [ 
     { 
      "style": "normal", 
      "type": "Container", 
      "separation": "strong", 
      "items": [ 
       { 
        "type": "ActionSet", 
        "actions": [ 
         { 
          "type": "Action.OpenUrl", 
          "url": "http://foo.bar.com", 
          "title": "adaptivecards1" 
         } 
        ] 
       }, 
       { 
        "type": "ColumnSet", 
        "separation": "strong", 
        "columns": [ 
         { 
          "type": "Column", 
          "size": 1, 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": "Title", 
            "size": "large", 
            "isSubtle": true 
           }, 
           { 
            "type": "TextBlock", 
            "text": "Model: ABC", 
            "size": "small" 
           } 
          ] 
         }, 
         { 
          "type": "Column", 
          "size": "1", 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": " " 
           }, 
           { 
            "type": "Image", 
            "url": "https://path/to/image.jpg", 
            "size": "large", 
            "horizontalAlignment": "right" 
           } 
          ] 
         } 
        ] 
       } 
      ] 
     }, 
     { 
      "style": "normal", 
      "type": "Container", 
      "separation": "strong", 
      "items": [ 
       { 
        "type": "ActionSet", 
        "actions": [ 
         { 
          "type": "Action.OpenUrl", 
          "url": "http://foo.bar.com", 
          "title": "adaptivecards2" 
         } 
        ] 
       }, 
       { 
        "type": "ColumnSet", 
        "separation": "strong", 
        "columns": [ 
         { 
          "type": "Column", 
          "size": 1, 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": "Another Title", 
            "size": "large", 
            "isSubtle": true 
           }, 
           { 
            "type": "TextBlock", 
            "text": "Model: XYZ", 
            "size": "small" 
           } 
          ] 
         }, 
         { 
          "type": "Column", 
          "size": "1", 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": " " 
           }, 
           { 
            "type": "Image", 
            "url": "https://path/to/other/image.jpg", 
            "size": "large", 
            "horizontalAlignment": "right" 
           } 
          ] 
         } 
        ] 
       } 
      ] 
     } 
    ] 
} 

enter image description here

Ceci est également discuté here.