Back to view formats
View formattingSharePoint Online

Reorder and Expand Board Items

This sample allow users to manage card order in Board Views and also enables expanding and collapsing images. This sample has the option 'Move to Top' that allows users to move cards to the top of the board view as a way to rearrange card positions.

Reorder and Expand Board Items formatting preview
Sample preview · View original animation

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

View formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideSelection": false,
  "formatter": {
    "elmType": "div",
    "attributes": {
      "class": "sp-card-container sp-card-container-noPadding"
    },
    "children": [
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer sp-card-subContainer-borderRadius"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "padding": "10px"
            },
            "attributes": {
              "iconName": "DoubleChevronUp"
            },
            "txtContent": "Move to Top",
            "customRowAction": {
              "action": "setValue",
              "actionInput": {
                "Order0": "=Number(@now)"
              }
            }
          },
          {
            "elmType": "div",
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label sp-card-boldText"
                },
                "txtContent": "[!Title.DisplayName]"
              },
              {
                "elmType": "p",
                "attributes": {
                  "title": "[$Title]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent",
                  "role": "heading",
                  "aria-level": "3"
                },
                "txtContent": "=if ([$Title] == '', '–', [$Title])"
              }
            ],
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            }
          },
          {
            "elmType": "div",
            "style": {
              "display": "=if ([$Image] == '', 'none', '')"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label sp-card-boldText"
                },
                "children": [
                  {
                    "elmType": "div",
                    "style": {
                      "display": "inline-block",
                      "font-size": "20px"
                    },
                    "attributes": {
                      "iconName": "=if([$Expand] == true, 'Blocked2','CirclePlus')"
                    },
                    "customRowAction": {
                      "action": "setValue",
                      "actionInput": {
                        "Expand": "=if([$Expand] == true, 0,1)"
                      }
                    }
                  },
                  {
                    "elmType": "div",
                    "style": {
                      "display": "inline-block",
                      "padding-left": "5px"
                    },
                    "attributes": {
                      "class": "ms-fontColor-neutralSecondary sp-card-label sp-card-boldText"
                    },
                    "txtContent": "[!Image.DisplayName]"
                  }
                ]
              },
              {
                "elmType": "img",
                "style": {
                  "display": "=if([$Expand] == true, '','none')",
                  "width": "80px"
                },
                "attributes": {
                  "src": "[$Image]",
                  "title": "[$Image]",
                  "class": "ms-fontColor-neutralPrimary"
                }
              }
            ],
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            }
          },
          {
            "elmType": "div",
            "style": {
              "display": "none"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label sp-card-boldText"
                },
                "txtContent": "[!Category.DisplayName]"
              },
              {
                "elmType": "div",
                "attributes": {
                  "class": "sp-card-content sp-card-formatterRef"
                },
                "children": [
                  {
                    "columnFormatterReference": "[$Category]"
                  }
                ]
              }
            ],
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            }
          },
          {
            "elmType": "div",
            "style": {
              "display": "none"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label sp-card-boldText"
                },
                "txtContent": "[!Order0.DisplayName]"
              },
              {
                "elmType": "p",
                "style": {
                  "display": "none"
                },
                "attributes": {
                  "title": "[$Order0]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content"
                },
                "txtContent": "=if ([$Order0] == '', '–', [$Order0])"
              }
            ],
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            }
          },
          {
            "elmType": "div",
            "style": {
              "display": "none"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label sp-card-boldText"
                },
                "txtContent": "[!Expand.DisplayName]"
              },
              {
                "elmType": "p",
                "attributes": {
                  "title": "=if ([$Expand.displayValue] == '', '–', [$Expand.displayValue])",
                  "class": "ms-fontColor-neutralPrimary sp-card-content"
                },
                "txtContent": "=if ([$Expand.displayValue] == '', '–', [$Expand.displayValue])"
              }
            ],
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            }
          }
        ]
      }
    ]
  }
}

From the contributor

How to use this sample

Summary

This sample allow users to manage card order in Board Views and also enables expanding and collapsing images. This sample has the option "Move to Top" that allows users to move cards to the top of the board view as a way to rearrange card positions.

screenshot of the sample

View requirements

  • The format expect the following fields:
Field Type
Title Single line of text
Category Choice - Include the following options "Started,Pending,Completed"
Order Single line of text - Manage the order of cards
Image Single line of text - This field allow to include url to image.
Expand Yes/No - default value "No"

Create Board View

  • Access to View dropdown and select "Create new view"
  • Add new Name and select option "Board"

Edit List View requirements

  • Access to List Settings > access to "Views" area and select created view.
  • Edit View where format will be included:
    • Access to "Sort" Area and select column "Order" and check as descending order, this option order the cards based on changed.

Sample

Solution Author(s)
reorder-expand-board-items.json André Lage

Version history

Version Date Comments
1.0 February 15, 2022 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.