Skip to content

Commit 2255566

Browse files
thechriskentVesaJuvonen
authored andcommitted
Added Additional Details (SharePoint#2382)
* Added Additional Details - Added Currency to unsupported column types - Added note about icons not being included in sp-field-severity classes - Added note about using other UI Fabric classes - Added link to Column Formatter * Updated schema reference in all sample code
1 parent 745f1f0 commit 2255566

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

docs/declarative-customization/column-formatting.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The simplest column formatting is one that places the value of the field inside
5555

5656
```JSON
5757
{
58+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
5859
"elmType": "div",
5960
"txtContent": "@currentField"
6061
}
@@ -66,6 +67,7 @@ Some field types require a bit of extra work to retrieve their values. Person fi
6667

6768
```JSON
6869
{
70+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
6971
"elmType": "div",
7072
"txtContent": "@currentField.title"
7173
}
@@ -77,6 +79,7 @@ Lookup fields are also represented as objects; the display text is stored in the
7779

7880
```JSON
7981
{
82+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
8083
"elmType": "div",
8184
"txtContent": "@currentField.lookupValue"
8285
}
@@ -95,7 +98,7 @@ This example uses an Excel-style conditional expression (`=if`) to apply a class
9598

9699
```JSON
97100
{
98-
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
101+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
99102
"debugMode": true,
100103
"elmType": "div",
101104
"attributes": {
@@ -132,7 +135,7 @@ This pattern is useful when you want different values to map to different levels
132135

133136
```JSON
134137
{
135-
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
138+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
136139
"debugMode": true,
137140
"elmType": "div",
138141
"attributes": {
@@ -174,7 +177,7 @@ This example colors the current field red when the value inside an item's DueDat
174177
175178
```JSON
176179
{
177-
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
180+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
178181
"elmType": "div",
179182
"debugMode": true,
180183
"txtContent": "@currentField",
@@ -192,6 +195,7 @@ This example demonstrates an alternate syntax to express a conditional expressio
192195

193196
```JSON
194197
{
198+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
195199
"elmType": "div",
196200
"txtContent": "@currentField",
197201
"style": {
@@ -226,6 +230,7 @@ To compare a date/time field value against another date constant, use the `Date(
226230

227231
```JSON
228232
{
233+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
229234
"elmType": "div",
230235
"txtContent": "@currentField",
231236
"style": {
@@ -264,6 +269,7 @@ This example shows how to turn a text field that contains stock ticker symbols i
264269

265270
```JSON
266271
{
272+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
267273
"elmType": "a",
268274
"txtContent": "@currentField",
269275
"attributes": {
@@ -286,6 +292,7 @@ You can use column formatting to render quick action links next to fields. The f
286292

287293
```JSON
288294
{
295+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
289296
"elmType": "div",
290297
"children": [
291298
{
@@ -331,7 +338,7 @@ This example applies `background-color` and `border-top` styles to create a data
331338

332339
```JSON
333340
{
334-
"debugMode": true,
341+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
335342
"elmType": "div",
336343
"txtContent": "@currentField",
337344
"attributes": {
@@ -353,7 +360,7 @@ This example relies on two number fields, `Before` and `After`, for which the va
353360

354361
```JSON
355362
{
356-
"debugMode": true,
363+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
357364
"elmType": "div",
358365
"children": [
359366
{
@@ -477,6 +484,7 @@ The following are not currently supported:
477484
* Filename (in Document Libraries)
478485
* Calculated
479486
* Retention Label
487+
* Currency
480488

481489
## Style guidelines
482490

@@ -497,6 +505,10 @@ You can use the following predefined classes for several common scenarios.
497505
| sp-field-trending--down |![Red arrow with number 100](../images/sp-columnformatting-trendingdown.png) |
498506
| sp-field-quickAction |![Name with mail icon](../images/sp-columnformatting-quickaction.png) |
499507

508+
> Note - The icons shown above for the `sp-field-severity` classes are **NOT** part of the class. Only the background color is included. Icons can be added by using the `iconName` attribute.
509+
510+
In addition to the classes listed above, the classes (such as the theme color, typography, grid system, etc.) defined by the Office UI Fabric can be used. For details, see the [Fabric website](https://dev.office.com/fabric#/styles/icons).
511+
500512
### Predefined icons
501513

502514
You can use predefined icons from Office UI Fabric. For details, see the [Fabric website](https://dev.office.com/fabric#/styles/icons).
@@ -522,6 +534,8 @@ Creating custom column formatting JSON from scratch is simple if you understand
522534
> [!TIP]
523535
> At any point, select **Ctrl**+**Space** to have Visual Studio Code offer suggestions for properties and values. For more information, see [Editing JSON with Visual Studio Code](https://code.visualstudio.com/Docs/languages/json).
524536
537+
> [!TIP]
538+
> SharePoint Patterns and Practices provides a free web part, [Column Formatter](https://github.com/SharePoint/sp-dev-solutions/blob/master/solutions/ColumnFormatter/docs/documentation/docs/getting-started.md), that can be used to edit and apply formats directly in the browser.
525539
526540
## Detailed syntax reference
527541

@@ -547,6 +561,7 @@ Any other value will result in an error.
547561

548562
```JSON
549563
{
564+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
550565
"elmType": "button",
551566
"txtContent": "Open this item",
552567
"customRowAction": {
@@ -559,6 +574,7 @@ Any other value will result in an error.
559574

560575
```JSON
561576
{
577+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
562578
"elmType": "button",
563579
"txtContent": "Share this item",
564580
"customRowAction": {
@@ -720,6 +736,7 @@ The following example shows the value of a style object. In this example, two st
720736

721737
```JSON
722738
{
739+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
723740
"padding": "4px",
724741
"background-color": {
725742
"operator": "?",
@@ -757,6 +774,7 @@ Any other attribute name will result in an error. Attribute values can either be
757774

758775
```JSON
759776
{
777+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
760778
"target": "_blank",
761779
"href": "='http://finance.yahoo.com/quote/' + @currentField"
762780
}
@@ -807,6 +825,7 @@ The following example contains an Expression object that performs the following
807825

808826
```JSON
809827
{
828+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
810829
"operator": "?",
811830
"operands": [
812831
{
@@ -936,6 +955,7 @@ For example, the following JSON will display the current field (assuming it's a
936955

937956
```JSON
938957
{
958+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
939959
"elmType": "div",
940960
"txtContent": {
941961
"operator": "toLocaleString()",
@@ -961,6 +981,7 @@ The following example shows how a lookup field might be used on a current field.
961981

962982
```JSON
963983
{
984+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
964985
"elmType": "a",
965986
"txtContent": "@currentField.lookupValue",
966987
"attributes": {
@@ -994,6 +1015,7 @@ The following example shows how a hyperlink field might be used on a current fie
9941015

9951016
```JSON
9961017
{
1018+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
9971019
"elmType": "a",
9981020
"txtContent": "@currentField.desc",
9991021
"attributes": {
@@ -1005,7 +1027,7 @@ The following example shows how a hyperlink field might be used on a current fie
10051027

10061028
#### "[$FieldName]"
10071029

1008-
The column is formatted within the context of the entire row. You can use this context to reference the values of other fields within the same row by specififying the **internal name** of the field surrounded by square brackets and preceeded by a dollar sign: `[$InternalName]`. For example, to get the value of a field with an internal name of "MarchSales", use `[$MarchSales]`.
1030+
The column is formatted within the context of the entire row. You can use this context to reference the values of other fields within the same row by specifying the **internal name** of the field surrounded by square brackets and preceeded by a dollar sign: `[$InternalName]`. For example, to get the value of a field with an internal name of "MarchSales", use `[$MarchSales]`.
10091031

10101032
If the value of a field is an object, the object's properties can be accessed. For example, to access the "Title" property of a person field named "SalesLead", use "[$SalesLead.title]".
10111033

@@ -1017,6 +1039,7 @@ This field can be used to display the current user's email address, but more lik
10171039

10181040
```JSON
10191041
{
1042+
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
10201043
"elmType": "div",
10211044
"txtContent": "@currentField.title",
10221045
"style": {

0 commit comments

Comments
 (0)