Skip to content

Commit 2d5408f

Browse files
authored
Column and View formatting documentation update (SharePoint#7387)
* Support indexOf and lastIndexOf for Arrays * Support fillHorizontally for tiles * Support p tag * Allow SVG style attributes * Allow dragable attribute * Support AverateRating column * Support Likes column * Allow tel: protocol * Support getUserImage operator * More updates for getUserImage op * Update date
1 parent 45072b0 commit 2d5408f

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

docs/declarative-customization/column-formatting.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Use column formatting to customize SharePoint
33
description: Customize how fields in SharePoint lists and libraries are displayed by constructing a JSON object that describes the elements that are displayed when a field is included in a list view, and the styles to be applied to those elements.
4-
ms.date: 09/28/2021
4+
ms.date: 10/08/2021
55
ms.localizationpriority: high
66
---
77

@@ -289,7 +289,9 @@ Here's the same sample from above, using the Excel-style expression syntax:
289289

290290
## Create clickable actions
291291

292-
You can use column formatting to provide hyperlinks that go to other webpages, or start custom functionality. This functionality is limited to static links that can be parameterized with values from fields in the list. You can't use column formatting to output links to protocols other than `http://`, `https://`, or `mailto:`.
292+
You can use column formatting to provide hyperlinks that go to other webpages, or start custom functionality. This functionality is limited to static links that can be parameterized with values from fields in the list. You can't use column formatting to output links to protocols other than `http://`, `https://`, `mailto:` or `tel:`.
293+
294+
`tel:` protocol only allows digits, `*+#` special characters and `.-/()` visual separators.
293295

294296
### Turn field values into hyperlinks (basic)
295297

@@ -683,7 +685,7 @@ This examples uses operator `loopIndex` to control the margins all rows but the
683685
{
684686
"elmType": "img",
685687
"attributes": {
686-
"src": "=[$person.picture]"
688+
"src": "=getUserImage([$person.email], 'S')"
687689
},
688690
"style": {
689691
"width": "3em",
@@ -797,7 +799,7 @@ Both the example uses defaultHoverField
797799
"margin": "2px"
798800
},
799801
"attributes": {
800-
"src": "='/_layouts/15/userphoto.aspx?size=S&accountname=' + [$Editor.email]",
802+
"src": "='getUserImage([$Editor.email], 's')",
801803
"title": "[$Editor.title]"
802804
}
803805
},
@@ -936,6 +938,8 @@ The following column types support column formatting:
936938
* Title (in Lists)
937939
* Yes/No
938940
* Managed Metadata
941+
* Average Rating
942+
* Likes
939943

940944
The following are currently **not** supported:
941945

@@ -998,6 +1002,7 @@ Specifies the type of element to create. Valid elements include:
9981002
- svg
9991003
- path
10001004
- button
1005+
- p
10011006

10021007
Any other value will result in an error.
10031008

@@ -1210,6 +1215,9 @@ An optional property that specifies style attributes to apply to the element spe
12101215
'text-wrap'
12111216
'word-break'
12121217
'word-wrap'
1218+
1219+
'stroke'
1220+
'fill-opacity'
12131221
```
12141222

12151223
The following example shows the value of a style object. In this example, two style properties (`padding` and `background-color`) will be applied. The `padding` value is a hard-coded string value. The `background-color` value is an Expression that is evaluated to either red (`#ff0000`) or green (`#00ff00`) depending on whether the value of the current field (specified by `@currentField`) is less than 40. For more information, see the Expression object section.
@@ -1268,6 +1276,7 @@ An optional property that specifies additional attributes to add to the element
12681276
- data-interception
12691277
- viewBox
12701278
- preserveAspectRatio
1279+
- draggable
12711280

12721281
Any other attribute name will result in an error. Attribute values can either be Expression objects or strings. The following example adds two attributes (`target` and `href`) to the element specified by `elmType`. The `target` attribute is hard-coded to a string. The `href` attribute is an expression that will be evaluated at runtime to http://finance.yahoo.com/quote/ + the value of the current field (`@currentField`).
12731282

@@ -1420,6 +1429,7 @@ Operators specify the type of operation to perform. The following operators are
14201429
- replace
14211430
- padStart
14221431
- padEnd
1432+
- getUserImage
14231433

14241434
**Binary arithmetic operators** - The following are the standard arithmetic binary operators that expect two operands:
14251435

@@ -1496,20 +1506,20 @@ Operators specify the type of operation to perform. The following operators are
14961506

14971507
**Binary operators** - The following are operators that expect two operands:
14981508

1499-
- **indexOf**: takes 2 operands. The first is the text you would like to search within, the second is the text you would like to search for. Returns the index value of the first occurrence of the search term within the string. Indexes start at 0. If the search term is not found within the text, -1 is returned. This operator is case-sensitive. - _Only available in SharePoint Online_
1509+
- **indexOf**: takes 2 operands. The first is the text (or array) you would like to search within, the second is the text you would like to search for. Returns the index value of the first occurrence of the search term within the string (or array). Indexes start at 0. If the search term is not found within the text (or array), -1 is returned. This operator is case-sensitive. - _Only available in SharePoint Online_
15001510
- `"txtContent": "=indexOf('DogFood', 'Dog')"` results in _0_
15011511
- `"txtContent": "=indexOf('DogFood', 'F')"` results in _3_
15021512
- `"txtContent": "=indexOf('DogFood', 'Cat')"` results in _-1_
15031513
- `"txtContent": "=indexOf('DogFood', 'f')"` results in _-1_
1504-
1514+
15051515
- **join**: takes 2 operands. The first is an array (multi-select person or choice field) and the second is the separating string. Returns a string concatenation of the array values separated by the separating string. - _Only available in SharePoint Online_
15061516
- `"txtContent": "=join(@currentField, ', ')"` might result in _"Apple, Orange, Cherry"_ (depending on the selected values)
15071517
- `"txtContent": "=join(@currentField.title, '|')"` might result in _"Chris Kent|Vesa Juvonen|Jeff Teper"_ (depending on the selected persons)
15081518

15091519
- **pow**: returns the base to the exponent power. - _Only available in SharePoint Online_
15101520
- `"txtContent":"=pow(2,3)"` results in _8_
15111521

1512-
- **lastIndexOf**: returns the position of the last occurrence of a specified value in a string
1522+
- **lastIndexOf**: returns the position of the last occurrence of a specified value in a string (or array)
15131523
- `"txtContent": "=lastIndexOf('DogFood DogFood', 'Dog')"` results in _8_
15141524
- `"txtContent": "=lastIndexOf('DogFood DogFood', 'F')"` results in _11_
15151525
- `"txtContent": "=lastIndexOf('DogFood DogFood', 'Cat')"` results in _-1_
@@ -1523,6 +1533,14 @@ Operators specify the type of operation to perform. The following operators are
15231533
- `"txtContent":"=endsWith('DogFood', 'Dog')"` results in _false_
15241534
- `"txtContent":"=endsWith('DogFood', 'Food')"` results in _true_
15251535

1536+
- **getUserImage**: returns a URL pointing to user's profile image for a given email and preferred size
1537+
- `"src":"=getUserImage('[email protected]', 'small')"` returns a URL pointing to user's profile picture in small resolution
1538+
- `"src":"=getUserImage('[email protected]', 's')"` returns a URL pointing to user's profile picture in small resolution
1539+
- `"src":"=getUserImage('[email protected]', 'medium')"` returns a URL pointing to user's profile picture in medium resolution
1540+
- `"src":"=getUserImage('[email protected]', 'm')"` returns a URL pointing to user's profile picture in medium resolution
1541+
- `"src":"=getUserImage('[email protected]', 'large')"` returns a URL pointing to user's profile picture in large resolution
1542+
- `"src":"=getUserImage('[email protected]', 'l')"` returns a URL pointing to user's profile picture in large resolution
1543+
15261544
**Ternary operators** - The following are operators that expect three operands:
15271545

15281546
- **substring**: returns the part of the string between the start and end indices. - _Only available in SharePoint Online_

docs/declarative-customization/view-formatting.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Use view formatting to customize SharePoint
33
description: Customize how views in SharePoint lists and libraries are displayed by constructing a JSON object that describes the elements that are displayed in a list view, and the styles to be applied to those elements.
4-
ms.date: 09/14/2021
4+
ms.date: 10/08/2021
55
ms.localizationpriority: high
66
---
77

@@ -821,6 +821,10 @@ Optional element. Specifies whether the ability to select rows in the view is di
821821

822822
For list & compact list layout, `hideSelection` only takes effect when there's a `rowFormatter` element specified. If no `rowFormatter` is specified, then `hideSelection` is ignored.
823823

824+
### fillHorizontally
825+
826+
Optional element. Specifies whether the cards in the row should be stretched horizontally to fill the row. `false` is the default behavior (meaning cards in a row are stacked without resizing until they overflow). `true` means cards in the row are stretched horizontally only if necessary to fill the row. Only valid for 'Gallery' layout.
827+
824828
### hideColumnHeader
825829

826830
Optional element. Specifies whether the column headers in the view are hidden or not. `false` is the default behavior inside a list view (meaning column headers will be visible). `true` means that the view will not display column headers. Only valid for 'List' and 'Compact List' layouts.

0 commit comments

Comments
 (0)