You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use column formatting to apply styles to each member of a multi-value field of type Person, Lookup and Choice.
467
+
468
+
### Basic text formatting
469
+
The following image shows an example of multi-value field formatting applied to a Person field.
470
+
471
+

472
+
473
+
This example uses the `length` operator to detect the number of members of the field, and used `join` operator to concatenate the email addresses of all members. This example hides the button when no member is found, and takes care of plurals in the text.
The following image showsn an example of building a list of users with pictures, email addresses and a simple counter at the top.
563
+
564
+

565
+
566
+
This examples uses operator `loopIndex` to control the margins all rows but the first one, and attribute `forEach` to build the list of members.
@@ -797,6 +985,20 @@ An optional property that specifies child elements of the element specified by `
797
985
798
986
An optional property that is meant for debugging. It outputs error messages and logs warnings to the console.
799
987
988
+
### forEach
989
+
990
+
An optional property that allows an element to duplicate itself for each member of a specific multi-value field. The value of `"forEach"` property should be in the format of either `"iteratorName in @currentField"` or `"iteratatorName in [$FieldName]"`.
991
+
992
+
`iteratorName` represents the name of iterator variable that is used to represent the current member of the multi-value field. The name of the iterator can be any combination of alphanumeric characters and underscore (`_`) that does not start with a digit.
993
+
994
+
The field used in the loop must be in a supported field type with multi-value option enabled: Person, Lookup, and Choice.
995
+
996
+
In the element with `forEach` or its childern elements, the iterator variable can be referred as if it is a new field. The index of the iterator can be accessed with `loopIndex` operator.
997
+
998
+
`forEach` cannot be applied to the root element, and will render no element if there is no value in the field.
999
+
1000
+
See [here](#formatting-multi-value-fields) for examples.
1001
+
800
1002
### Expressions
801
1003
802
1004
Values for `txtContent`, style properties, and attribute properties can be expressed as expressions, so that they are evaluated at runtime based on the context of the current field (or row). Expression objects can be nested to contain other Expression objects.
@@ -892,6 +1094,9 @@ Operators specify the type of operation to perform. The following operators are
892
1094
- toLocaleString()
893
1095
- toLocaleDateString()
894
1096
- toLocaleTimeString()
1097
+
- length
1098
+
- join
1099
+
- loopIndex
895
1100
896
1101
**Binary operators** - The following are the standard arithmetic binary operators that expect two operands:
897
1102
@@ -914,13 +1119,29 @@ Operators specify the type of operation to perform. The following operators are
914
1119
- toLocaleString()
915
1120
- toLocaleDateString()
916
1121
- toLocaleTimeString()
1122
+
- length
1123
+
- loopIndex
917
1124
918
1125
**Conditional operator** - The conditional operator is:
919
1126
920
1127
- ?
921
1128
922
1129
This is to achieve an expression equivalent to a ? b : c, where if the expression a evaluates to true, then the result is b, else the result is c.
923
1130
1131
+
**Multi-value field-related operators** - The following operators are only used in a context with multi-value field of type Person, Lookup, or Choice.
1132
+
1133
+
- length
1134
+
- join
1135
+
- loopIndex
1136
+
1137
+
`length`, when provided with a field name, returns the number of members in a multi-valued field. When a single-value field is provided, `length` will return 1 when there is a value in that field.
1138
+
1139
+
`join` concatenates values in a multi-value field with a specified separator. The first operand shall point to a value in a multi-value field, e.g. `"@currentField.lookupValue"`, `"[$AssignedTo.title]"`. The second operand shall be a string literal that is the separator that joins the values together.
1140
+
1141
+
`loopIndex`, when provided with a name of iterator variable, returns the current index (starting from 0) of the iterator. The name of iterator must be provided as a string literal. `loopIndex` would only work within the element with respective `forEach` enabled or its children elements.
1142
+
1143
+
See [here](#formatting-multi-value-fields) for examples.
1144
+
924
1145
### operands
925
1146
926
1147
Specifies the parameters, or operands for an expression. This is an array of Expression objects or base values.
@@ -1086,6 +1307,37 @@ This will evaluate to a number equal to the height of the browser window (in pix
1086
1307
1087
1308
This will evaluate to a number equal to the width of the browser window (in pixels) when the list was rendered.
1088
1309
1310
+
#### Thumnails
1311
+
1312
+
In a document library, there is a series of tokens that can be used to retrieve the URL to the thumbnail of a file, including:
1313
+
1314
+
-`@thumbnail.small`, `@thumbnail.medium`, and `@thumbnail.large` evaluate to the thumbnail URL in 3 different predefined sizes.
1315
+
-`@thumbnail.<bounding size>` evaluates to the URL to the largest thumbnails that is not larger than the bounding size in both width and height. For example, `@thumbnail.150` evaluates to the URL to a thumbnail not larger than 150×150 pixels.
1316
+
-`@thumbnail.<bounding width>x<bounding height>` evaluates to the URL to the largest thumbnail that is not larger than the bounding width and bounding height. For example, `@thumbnail.100x200` evaluates to the URL to a thumbnail not wider than 100 pixels and not higher than 200 pixels.
1317
+
1318
+
These tokens will yield no value on non-file items including folders.
1319
+
1320
+
> [!NOTE]
1321
+
> The aspect ratio of thumbnail generated is the same as how the file looks like, changing the bounding sizes will not affect the aspect ratio of the thumbnail.
1322
+
1323
+
> [!TIP]
1324
+
> Thumbnails are only available for a list of supported file formats. It means that sometimes the URL generated is not accessible due to lack of support on certain formats. However, if a valid thumbnail token is set as the _only_`src` attribute of an `img` tag, we will take care of it and hide the image when it is not available.
0 commit comments