Skip to content

Commit a8c6a28

Browse files
ldemarisVesaJuvonen
authored andcommitted
Update view-formatting.md (SharePoint#2112)
1 parent c253214 commit a8c6a28

File tree

1 file changed

+81
-6
lines changed

1 file changed

+81
-6
lines changed

docs/declarative-customization/view-formatting.md

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ The easiest way to use view formatting is to start from an example and edit it t
3030

3131
You can use view formatting to apply a class to a list view row, depending on the value of one or more fields in the row. These examples leave the content and structure of list view rows intact.
3232

33-
Any conditional formatting scenario
34-
3533
For a list of recommended classes to use inside view formats, please see the [Style Guidelines section](https://github.com/SharePoint/sp-dev-docs/blob/master/docs/declarative-customization/column-formatting.md#style-guidelines) in the [Column Formatting reference document.](https://github.com/SharePoint/sp-dev-docs/blob/master/docs/declarative-customization/column-formatting.md)
3634

3735
### Conditional formatting based on a date range
@@ -61,8 +59,6 @@ This example applies the class `sp-field-severity--severeWarning` to a list view
6159

6260
### Conditional formatting based on the value in a text or choice field
6361

64-
The following image shows a list view with conditional formatting applied based on the value inside a choice field:
65-
6662
This example was adopted from a column formatting example, [Conditional formatting based on the value in a text of choice field](https://github.com/ldemaris/sp-dev-docs/blob/patch-7/docs/declarative-customization/column-formatting.md#conditional-formatting-based-on-the-value-in-a-text-or-choice-field-advanced), with some important differences to apply the concept to list view rows. The column formatting example applies both an icon and a class to a column based on the value of `@currentField`. The `additionalRowClass` attribute in view formatting, however, only allows you to specify a class and not an icon. Additionally, since `@currentField` always resolves to the value of the Title field when referenced inside a view format, this sample refers to the `$Status` field directly to determine which class to apply to the row.
6763

6864
```JSON
@@ -147,7 +143,86 @@ This example was adopted from a column formatting example, [Conditional formatti
147143

148144
You can use view formatting to define a totally custom layout of field values inside a row.
149145

150-
### Multi-line view
146+
### Multi-line view style
147+
148+
The following image shows a list with a custom multi-line view style applied:
149+
150+
This example uses the `rowFormatter` element, which is used to totally override the rendering of a list view row. The `rowFormatter` in this example creates e a bounding `<div />` for every list view row. Inside this bounding box for every row, the `$Title` and `$Feedback` fields are displayed on separate lines. Under those fields, a `button` element is displayed that, when clicked, does the same thing as clicking the list row in an uncustomized view, which is opening the property form for the item. This `button` is displayed conditionally, when the value of the `$Assigned_x0020_To` field (assumed to be a person/group field) matches the current signed-in user.
151+
152+
```JSON
153+
{
154+
"hideSelection": "true",
155+
"hideListHeader": "true",
156+
"rowFormatter": {
157+
"elmType": "div",
158+
"style": {
159+
"padding": "12px",
160+
"overflow": "hidden",
161+
"border-radius": "2px",
162+
"box-shadow": "0 1.6px 3.6px 0 #dddddd, 0 0.3px 0.9px 0 #e3e3e3",
163+
"margin-bottom": "12px"
164+
},
165+
"children": [
166+
{
167+
"elmType": "div",
168+
"style": {
169+
"text-align": "left"
170+
},
171+
"children": [
172+
{
173+
"elmType": "div",
174+
"style": {
175+
"font-size": "16px",
176+
"font-weight": "600",
177+
"padding-bottom": "8px"
178+
},
179+
"txtContent": "[$Title]"
180+
},
181+
{
182+
"elmType": "div",
183+
"txtContent": "[$Feedback]",
184+
"style": {
185+
"padding-bottom": "4px"
186+
}
187+
},
188+
{
189+
"elmType": "button",
190+
"customRowAction": {
191+
"action": "defaultClick"
192+
},
193+
"txtContent": "Give feedback",
194+
"style": {
195+
"cursor": "pointer",
196+
"font-weight": "600",
197+
"background-color": "#f4f4f4",
198+
"border": "1px solid transparent",
199+
"margin-top": "4px",
200+
"padding": "0 16 0 16px",
201+
"height": "32px",
202+
"border-radius": "2px",
203+
"box-shadow": "0 0 0 0 #ffffff",
204+
"display": {
205+
"operator": "?",
206+
"operands": [
207+
{
208+
"operator": "==",
209+
"operands": [
210+
"@me",
211+
"[$Assigned_x0020_To.email]"
212+
]
213+
},
214+
"",
215+
"none"
216+
]
217+
}
218+
}
219+
}
220+
]
221+
}
222+
]
223+
}
224+
}
225+
```
151226

152227
## Creating custom JSON
153228

@@ -174,7 +249,7 @@ Creating custom view formatting JSON from scratch is simple if you understand th
174249

175250
### rowFormatter
176251

177-
Optional element. Specifies a JSON object that describes a view format. The schema of this JSON object is identical to the schema of a column format. For details on this schema and its capabilities, see the [Column Format detailex syntax reference.](https://github.com/SharePoint/sp-dev-docs/blob/master/docs/declarative-customization/column-formatting.md#detailed-syntax-reference)
252+
Optional element. Specifies a JSON object that describes a list view row format. The schema of this JSON object is identical to the schema of a column format. For details on this schema and its capabilities, see the [Column Format detailex syntax reference.](https://github.com/SharePoint/sp-dev-docs/blob/master/docs/declarative-customization/column-formatting.md#detailed-syntax-reference)
178253

179254
#### Differences in behavior between the rowFormatter element and column formatting
180255

0 commit comments

Comments
 (0)