Formatting to set background colour of entire cell (not just text part)

Copper Contributor

I am using custom formatting along the following lines:

{
  "$schema": https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json,
  "elmType": "div",
  "txtContent": "@currentField",
  "attributes": {
    "class": "='ms-Link ' + if(endsWith([$FileLeafRef], '.msg'), 'sp-field-severity--good', '')"
  },
  "customRowAction": {
    "action": "defaultClick"
  }
}

This works fine, except that it only changes the background colour of the text part of the cell.  You can see in the following clip that, where the cell is larger (to fit content in other columns), the cell is larger than the textual content:

 

image001 (1).png

Is it possible to specify a background colour of the entire cell, based on file extension?

 

 

1 Reply

@drmrbrewer I was also looking for a solution on this one, did you end up finding anything? The only thing I found that may be helpful for your purposes is by setting the minimum height as per this post json - Change background color of a column in a sharepoint list - Stack Overflow - which may work for your list if the item heights are moreorless static. Unfortunately I am trying to do this on a multi-line text column with text wrapping, the content for which varies significantly with each item.