Skip to content

Commit f0cad38

Browse files
author
Marcin Wojciechowski
committed
Added quick docs
1 parent 44c56be commit f0cad38

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/documentation/docs/controls/ListItemAttachments.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ import { ListItemAttachments } from '@pnp/spfx-controls-react/lib/ListItemAttach
2929
disabled={false} />
3030
```
3131

32+
- If You want to use `ListItemAttachments` controls with new form You have to use React.createRef.
33+
34+
Following example will add selected attachments to list item with id = 1
35+
36+
```TypeScript
37+
let listItemAttachmentsComponentReference = React.createRef<ListItemAttachments>();
38+
...
39+
<ListItemAttachments
40+
ref={listItemAttachmentsComponentReference}
41+
context={this.props.context}
42+
listId="dfcfdb95-2488-4757-b55b-14d94166ad87"
43+
itemId={0} />
44+
...
45+
<PrimaryButton text="Save to Item with id 1" onClick={()=>{
46+
//@ts-ignore
47+
listItemAttachmentsComponentReference.current.uploadAttachments(1);
48+
}} />
49+
```
50+
3251
## Implementation
3352

3453
The `ListItemAttachments` control can be configured with the following properties:
@@ -37,7 +56,7 @@ The `ListItemAttachments` control can be configured with the following propertie
3756
| Property | Type | Required | Description |
3857
| ---- | ---- | ---- | ---- |
3958
| context | BaseComponentContext | yes | SPFx web part or extention context |
40-
| itemId | number | yes | List Item Id |
59+
| itemId | number | no | List Item Id |
4160
| listId | string | yes | Guid of the list. |
4261
| webUrl | string | no | URL of the site. By default it uses the current site URL. |
4362
| disabled | boolean | no | Specifies if the control is disabled or not. |

0 commit comments

Comments
 (0)