11# ListItemPicker control
22
3- This control allows you to select one or more item from list, based in a column value, the control suggest values based on characters typed
3+ This control allows you to select one or more items from a list. The item selection is based from a column value. The control will suggest items based on the inserted value.
44
55Here is an example of the control:
66
@@ -16,110 +16,44 @@ Here is an example of the control:
1616- Import the control into your component:
1717
1818``` TypeScript
19-
2019import { ListItemPicker } from ' @pnp/spfx-controls-react/listItemPicker' ;
2120```
2221- Use the ` ListItemPicker ` control in your code as follows:
2322
2423``` TypeScript
25- < ListItemPicker
26- listId = ' da8daf15-d84f-4ab1-9800-7568f82fed3f'
27- columnInternalName = ' Title'
28- itemLimit = {2 }
29- onSelectedItem = {this.onSelectedItem }
30- context = {this.props.context }
31- / >
24+ < ListItemPicker listId = ' da8daf15-d84f-4ab1-9800-7568f82fed3f'
25+ columnInternalName = ' Title'
26+ itemLimit = {2 }
27+ onSelectedItem = {this.onSelectedItem }
28+ context = {this.props.context } / >
3229```
3330
3431- The ` onSelectedItem ` change event returns the list items selected and can be implemented as follows:
3532
3633``` TypeScript
3734private onSelectedItem (data : { key: string ; name : string }[]) {
38- for (const item of data ) {
39- console .log (` Item value: ${item .name } ` );
40- }
35+ for (const item of data ) {
36+ console .log (` Item value: ${item .name } ` );
4137 }
38+ }
4239```
4340## Implementation
4441
4542The ` ListItemPicker ` control can be configured with the following properties:
4643
47- <table style =" width : 100% ; height : 786px ;" >
48- <tbody >
49- <tr >
50- <th style =" width : 220px ;" >Property</th >
51- <th >Type</th >
52- <th style =" width : 85px ;" >Required</th >
53- <th >Description</th >
54- </tr >
55- <tr >
56- <td >listId</td >
57- <td >string</td >
58- <td >yes</td >
59- <td >Gui of List</td >
60- </tr >
61- <tr >
62- <td >columnInternalName</td >
63- <td >string</td >
64- <td >yes</td >
65- <td >InternalName of column to search and get values</td >
66- </tr >
67- <tr >
68- <td >onSelectedItem: (item:any) =>void;</td >
69- <td >function</td >
70- <td >yes</td >
71- <td >Callback function</td >
72- </tr >
73- <tr >
74- <td >className</td >
75- <td >string</td >
76- <td >no</td >
77- <td >CSS className</td >
78- </tr >
79- <tr >
80- <td >webUrl</td >
81- <td >string</td >
82- <td >no</td >
83- <td >URL of site if different of current site, user must have permissions</td >
84- </tr >
85- <tr >
86- <td >value</td >
87- <td >Array</td >
88- <td >no</td >
89- <td >Default Value</td >
90- </tr >
91- <tr >
92- <td >disabled</td >
93- <td >Boolean</td >
94- <td >no</td >
95- <td >Disable Control</td >
96- </tr >
97- <tr >
98- <td >itemLimit</td >
99- <td >number</td >
100- <td >yes</td >
101- <td >Number os items to select / return</td >
102- </tr >
103- <tr >
104- <td >context</td >
105- <td >WebPartContext|ApplicationCustomizerContext</td >
106- <td >yes</td >
107- <td >WebPart or Application customiser context</td >
108- </tr >
109- <tr >
110- <td >sugestedHeaderText</td >
111- <td >string</td >
112- <td >no</td >
113- <td >Text header to display</td >
114- </tr >
115- <tr >
116- <td >noresultsFoundTextstring</td >
117- <td >string</td >
118- <td >no</td >
119- <td >Text message when no items</td >
120- </tr >
121- </tbody >
122- </table >
12344
45+ | Property | Type | Required | Description |
46+ | ---- | ---- | ---- | ---- |
47+ | columnInternalName | string | yes | InternalName of column to search and get values. |
48+ | context | WebPartContext \| ApplicationCustomizerContext | yes | SPFx web part or extention context |
49+ | listId | string | yes | Guid of the list. |
50+ | itemLimit | number | yes | Number of items which can be selected |
51+ | onSelectItem | (items: any[ ] ) => void | yes | Callback function which returns the selected items. |
52+ | className | string | no | ClassName for the picker. |
53+ | webUrl | string | no | URL of the site. By default it uses the current site URL. |
54+ | defaultSelectedItems | any[ ] | no | Initial items that have already been selected and should appear in the people picker. |
55+ | suggestionsHeaderText | string | no | The text that should appear at the top of the suggestion box. |
56+ | noResultsFoundText | string | no | The text that should appear when no results are returned. |
57+ | disabled | boolean | no | Specifies if the control is disabled or not. |
12458
12559![ ] ( https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/ListItemPicker )
0 commit comments