|
| 1 | +# Taxonomy Picker |
| 2 | + |
| 3 | +This control Allows you to select one or more Terms from a TermSet via its name or TermSet ID. You can also configure the control to select the child terms from a specific term in the TermSet by setting the AnchorId. |
| 4 | + |
| 5 | +!!! note "Disclaimer" |
| 6 | + This control makes use of the `ProcessQuery` API end-points to retrieve the managed metadata information. This will get changed once the APIs for managing managed metadata will become available. |
| 7 | + |
| 8 | +**Empty term picker** |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +**Selecting terms** |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +**Selected terms in picker** |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +**Term picker: Auto Complete** |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +## How to use this control in your solutions |
| 26 | + |
| 27 | +- 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. |
| 28 | +- Import the following modules to your component: |
| 29 | + |
| 30 | +```TypeScript |
| 31 | +import { TaxonomyPicker, IPickerTerms } from "@pnp/spfx-controls-react/lib/TaxonomyPicker"; |
| 32 | +``` |
| 33 | + |
| 34 | +- Use the `TaxonomyPicker` control in your code as follows: |
| 35 | + |
| 36 | +```TypeScript |
| 37 | +<TaxonomyPicker |
| 38 | + allowMultipleSelections={true} |
| 39 | + TermSetNameOrID="Countries" |
| 40 | + panelTitle="Select Term" |
| 41 | + label="Taxonomy Picker" |
| 42 | + context={this.props.context} |
| 43 | + onChange={this.onTaxPickerChange} |
| 44 | + isTermSetSelectable={false} |
| 45 | +/> |
| 46 | +``` |
| 47 | + |
| 48 | +- With the `onChange` property you can capture the event of when the terms in the picker has changed: |
| 49 | + |
| 50 | +```typescript |
| 51 | +private onTaxPickerChange(terms : IPickerTerms) { |
| 52 | + console.log("Terms", terms); |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +## Implementation |
| 57 | + |
| 58 | +The TaxonomyPicker control can be configured with the following properties: |
| 59 | + |
| 60 | +| Property | Type | Required | Description | |
| 61 | +| ---- | ---- | ---- | ---- | |
| 62 | +| panelTitle | string | yes | TermSet Picker Panel title. | |
| 63 | +| label | string | yes | Text displayed above the Taxonomy Picker. | |
| 64 | +| disabled | string | no | Specify if the control needs to be disabled. | |
| 65 | +| context | WebPartContext | yes | Context of the current web part. | |
| 66 | +| initialValues | IPickerTerms | no | Defines the selected by default term sets. | |
| 67 | +| allowMultipleSelections | boolean | no | Defines if the user can select only one or many term sets. Default value is false. | |
| 68 | +| TermSetNameOrID | string | yes | The name or Id of your TermSet that you would like the Taxonomy Picker to chose terms from. | |
| 69 | +| onChange | function | no | captures the event of when the terms in the picker has changed. | |
| 70 | +| isTermSetSelectable | boolean | no | Specify if the TermSet itself is selectable in the tree view. | |
| 71 | +| anchorId | string | no | Set the anchorid to a child term in the TermSet to be able to select terms from that level and below. | |
| 72 | + |
| 73 | +Interface `IPickerTerm` |
| 74 | + |
| 75 | +| Property | Type | Required | Description | |
| 76 | +| ---- | ---- | ---- | ---- | |
| 77 | +| key | string | yes | The ID of the term | |
| 78 | +| name | string | yes | The name of the term | |
| 79 | +| path | string | yes | The path of the term | |
| 80 | +| termSet | string | yes | The Id of the parent TermSet of the term | |
| 81 | +| termSetName | string | no | The Name of the parent TermSet of the term | |
| 82 | + |
| 83 | +Interface `IPickerTerms` |
| 84 | + |
| 85 | +An Array of IPickerTerm |
| 86 | + |
| 87 | + |
0 commit comments