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
Copy file name to clipboardExpand all lines: docs/documentation/docs/controls/ListItemAttachments.md
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# ListItemAttachments control
2
2
3
-
This control allows you to manage list item attachments, you can add or delete associated attachments. The attachments are listed in tile view.
3
+
This control allows you to manage list item attachments, you can add or delete associated attachments. The attachments can be displayed in different modes: tiles (default), list, or compact list.
4
4
5
5
Here is an example of the control:
6
6
@@ -12,6 +12,10 @@ Here is an example of the control:

16
+
17
+

18
+
15
19
## How to use this control in your solutions
16
20
17
21
- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../../#getting-started) page for more information about installing the dependency.
@@ -30,6 +34,30 @@ import { ListItemAttachments } from '@pnp/spfx-controls-react/lib/ListItemAttach
30
34
disabled={false} />
31
35
```
32
36
37
+
- You can customize the display mode of attachments. Import the `AttachmentsDisplayMode` enum and use it:
- If you want to use `ListItemAttachments` controls with new form you have to use React.createRef.
34
62
35
63
Following example will add selected attachments to list item with id = 1
@@ -61,10 +89,21 @@ The `ListItemAttachments` control can be configured with the following propertie
61
89
| webUrl | string | no | URL of the site. By default it uses the current site URL. |
62
90
| label | string | no | Main text to display on the placeholder, next to the icon. |
63
91
| description | string | no | Description text to display on the placeholder, below the main text and icon. |
92
+
| displayMode | AttachmentsDisplayMode | no | Display mode for rendering attachments. Options: `AttachmentsDisplayMode.Tiles` (default), `AttachmentsDisplayMode.DetailsList`, or `AttachmentsDisplayMode.DetailsListCompact`. |
64
93
| disabled | boolean | no | Specifies if the control is disabled or not. |
65
94
| openAttachmentsInNewWindow | boolean | no | Specifies if the attachment should be opened in a separate browser tab. Use this property set to `true` if you plan to use the component in Microsoft Teams. |
66
95
| onAttachmentChange | (itemData: any) => void | no | Callback function invoked when attachments are added or removed. Receives the updated item data including the new ETag. This is useful when using the control within a form (like DynamicForm) that tracks ETags for optimistic concurrency control. |
67
96
97
+
enum `AttachmentsDisplayMode`
98
+
99
+
Display mode for rendering attachments.
100
+
101
+
| Value | Description |
102
+
| ---- | ---- |
103
+
| Tiles | Displays attachments as tiles/thumbnails using DocumentCard components. This is the default mode. |
104
+
| DetailsList | Displays attachments in a list format with file type icons, file names, and delete actions. |
105
+
| DetailsListCompact | Displays attachments in a compact list format with reduced row height and padding. |
106
+
68
107
## Usage with DynamicForm
69
108
70
109
When using `ListItemAttachments` within a `DynamicForm` or any component that uses ETags for optimistic concurrency control, you should use the `onAttachmentChange` callback to update the ETag when attachments are modified:
0 commit comments