SharePoint List Formatting

Introduction

SharePoint is a powerful tool for creating and managing lists of data. Lists can track information such as tasks, issues, and contacts. However, sometimes the default SharePoint list view may not be enough to display the information in the way that you want. This is where list formatting comes in. SharePoint list formatting allows you to customize how your list appears, making viewing and interacting with the data easier.

Types of List Formatting in Sharepoint

There are two types of list formatting in SharePoint.

View Formatting

View formatting allows you to customize the appearance of a full view of a SharePoint list. This can include things like font, color, and layout. You can also use view formatting to add functionality to the view, such as buttons and links.

To apply view formatting to a SharePoint list, you can use JSON code to define the formatting rules. This code can be added to the "Format View" option in the SharePoint list view settings.

Row Formatting

Row formatting allows you to customize the appearance of individual rows in a SharePoint list. This can include things like color coding based on the values in a column, hiding columns that are not relevant to the user, and adding icons or images.

To apply row formatting to a SharePoint list, you can use JSON code to define the formatting rules. This code can be added to the "Format this column" option in the SharePoint list column settings.

View formatting and row formatting can create a fully customized view of your SharePoint list. With SharePoint list formatting, you can create views tailored to your specific needs, making it easier to work with your data and increasing productivity.

How can we use view formatting and row formatting in SharePoint to customize the appearance of a list?

Let's say you have a SharePoint list that tracks tasks for your team. You want to customize the list view to easily see which tasks are overdue and which are on track.

To do this, you can use view formatting to change the background color of the rows based on the due date. For example, you can use the following JSON code to set the background color to red for overdue tasks and to green for tasks that are on track:

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": {
    "operator": ":",
    "operands": [
      {
        "operator": "<=",
        "operands": [
          "@now",
          "[$DueDate]"
        ]
      },
      "sp-css-backgroundColor-red",
      "sp-css-backgroundColor-green"
    ]
  }
}

You can apply this view formatting code by going to the list view settings and selecting "Format View". Paste the JSON code into the text box and click "Save".

Next, you can use row formatting to add an icon next to each task that indicates its priority. For example, you can add a red exclamation mark icon next to high-priority tasks using the following JSON code.

{
  "elmType": "span",
  "style": {
    "padding-right": "8px"
  },
  "attributes": {
    "iconName": {
      "operator": "?",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "[$Priority]",
            "High"
          ]
        },
        "Error",
        ""
      ]
    }
  }
}

You can apply this row formatting code by going to the list column settings and selecting "Format this column" for the "Priority" column. Paste the JSON code into the text box and click "Save".

Summary

With these view formatting and row formatting customizations, you now have a customized view of your SharePoint task list, making it easier to see which tasks are overdue and on track and which are high priority.