forked from pnp/sp-dev-fx-controls-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from SharePoint/dev
Dev
- Loading branch information
Showing
30 changed files
with
674 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# ListItemPicker control | ||
|
||
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. | ||
|
||
Here is an example of the control: | ||
|
||
![ListItemPicker select list items](../assets/ListItemPicker-selectlist.png) | ||
|
||
![ListItemPicker select list items](../assets/ListItemPicker-selectlist2.png) | ||
|
||
![ListItemPicker selected Items](../assets/ListItemPicker-selectedItems.png) | ||
|
||
## How to use this control in your solutions | ||
|
||
- 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. | ||
- Import the control into your component: | ||
|
||
```TypeScript | ||
import { ListItemPicker } from '@pnp/spfx-controls-react/listItemPicker'; | ||
``` | ||
- Use the `ListItemPicker` control in your code as follows: | ||
|
||
```TypeScript | ||
<ListItemPicker listId='da8daf15-d84f-4ab1-9800-7568f82fed3f' | ||
columnInternalName='Title' | ||
itemLimit={2} | ||
onSelectedItem={this.onSelectedItem} | ||
context={this.props.context} /> | ||
``` | ||
|
||
- The `onSelectedItem` change event returns the list items selected and can be implemented as follows: | ||
|
||
```TypeScript | ||
private onSelectedItem(data: { key: string; name: string }[]) { | ||
for (const item of data) { | ||
console.log(`Item value: ${item.name}`); | ||
} | ||
} | ||
``` | ||
## Implementation | ||
|
||
The `ListItemPicker` control can be configured with the following properties: | ||
|
||
|
||
| Property | Type | Required | Description | | ||
| ---- | ---- | ---- | ---- | | ||
| columnInternalName | string | yes | InternalName of column to search and get values. | | ||
| context | WebPartContext \| ApplicationCustomizerContext | yes | SPFx web part or extention context | | ||
| listId | string | yes | Guid of the list. | | ||
| itemLimit | number | yes | Number of items which can be selected | | ||
| onSelectItem | (items: any[]) => void | yes | Callback function which returns the selected items. | | ||
| className | string | no | ClassName for the picker. | | ||
| webUrl | string | no | URL of the site. By default it uses the current site URL. | | ||
| defaultSelectedItems | any[] | no | Initial items that have already been selected and should appear in the people picker. | | ||
| suggestionsHeaderText | string | no | The text that should appear at the top of the suggestion box. | | ||
| noResultsFoundText | string | no | The text that should appear when no results are returned. | | ||
| disabled | boolean | no | Specifies if the control is disabled or not. | | ||
|
||
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/ListItemPicker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './controls/listItemPicker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { WebPartContext } from "@microsoft/sp-webpart-base"; | ||
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base"; | ||
|
||
export interface IListItemPickerProps { | ||
columnInternalName: string; | ||
context: WebPartContext | ApplicationCustomizerContext; | ||
listId: string; | ||
itemLimit: number; | ||
|
||
className?: string; | ||
webUrl?: string; | ||
defaultSelectedItems?: any[]; | ||
disabled?: boolean; | ||
suggestionsHeaderText?:string; | ||
noResultsFoundText?:string; | ||
|
||
onSelectedItem: (item:any) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface IListItemPickerState { | ||
noresultsFoundText: string; | ||
showError: boolean; | ||
errorMessage: string; | ||
suggestionsHeaderText:string; | ||
} |
Oops, something went wrong.