0

I have a Gallery view for a teams list where I'm looking to have multiple attributes display or concatenate on the same line rather than be stacked on top of each other. For example, displaying the City and State attribute together as Denver, CO. Is there a way to do this in the Gallery view?

Example card

{
        "elmType": "div",
        "attributes": {
          "class": "sp-card-displayColumnContainer"
        },
        "children": [
          {
            "elmType": "p",
            "attributes": {
              "title": "[$City]",
              "class": "ms-fontColor-neutralPrimary sp-card-content "
            },
            "txtContent": "=if ([$City] == '', '–', [$City])"
          },
          {
            "elmType": "span",
            "attributes": {
              "title": "[$State]",
              "class": "ms-fontColor-neutralPrimary sp-card-content "
            },
            "txtContent": "=if ([$State] == '', '–', [$State])"
          }
        ]
      },

1 Answer 1

0

You can just concatenate like this [$City] + ', ' + [$State]

Overall code will look like below:

{
    "elmType": "div",
    "attributes": {
      "class": "sp-card-displayColumnContainer"
    },
    "children": [
      {
        "elmType": "p",
        "attributes": {
          "title": "[$City]",
          "class": "ms-fontColor-neutralPrimary sp-card-content "
        },
        "txtContent": "=if ([$City] == '', '–', [$City] + ', ' + [$State])"
      },
      {
        "elmType": "span",
        "attributes": {
          "title": "[$State]",
          "class": "ms-fontColor-neutralPrimary sp-card-content "
        },
        "txtContent": "=if ([$State] == '', '–', [$State])"
      }
    ]
  },
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.