@@ -68,7 +68,7 @@ Custom rendering of a More actions button that displays a context menu for each
68
68
customPanelWidth={700}
69
69
isLightDismiss={false}
70
70
isBlocking={false}
71
- onRenderActionButton={(termStoreInfo: ITermStoreInfo , termSetInfo: ITermSetInfo , termInfo?: ITermInfo ) => {
71
+ onRenderActionButton={(termStoreInfo: ITermStoreInfo , termSetInfo: ITermSetInfo , termInfo?: ITermInfo ): JSX . Element => {
72
72
const menuIcon: IIconProps = { iconName: ' MoreVertical' , " aria-label" : " More actions" , style: { fontSize: " medium" } };
73
73
if (termInfo ) {
74
74
const menuProps: IContextualMenuProps = {
@@ -147,4 +147,45 @@ The ModernTaxonomyPicker control can be configured with the following properties
147
147
| isBlocking | boolean | no | Whether the panel uses a modal overlay or not. |
148
148
| onRenderActionButton | function | no | Optional custom renderer for adding e.g. a button with additional actions to the terms in the tree view. |
149
149
150
- ![ ] ( https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/TaxonomyPicker )
150
+ ## Standalone TaxonomyTree control
151
+
152
+ You can also use the ` TaxonomyTree ` control separately to just render a stand-alone tree-view of a term set with action buttons.
153
+
154
+ - Use the ` TaxonomyTree ` control in your code as follows:
155
+ Initialize the taxonomy service and state, load basic info from term store and display the ` TaxonomyTree ` component.
156
+
157
+ ``` TypeScript
158
+ const taxonomyService = new SPTaxonomyService (props .context );
159
+ const [terms, setTerms] = React .useState <ITermInfo []>();
160
+ const [currentTermStoreInfo, setCurrentTermStoreInfo] = React .useState <ITermStoreInfo >();
161
+ const [currentTermSetInfo, setCurrentTermSetInfo] = React .useState <ITermSetInfo >();
162
+ const [currentLanguageTag, setCurrentLanguageTag] = React .useState <string >(" " );
163
+
164
+ React .useEffect (() => {
165
+ sp .setup (props .context );
166
+ taxonomyService .getTermStoreInfo ()
167
+ .then ((termStoreInfo ) => {
168
+ setCurrentTermStoreInfo (termStoreInfo );
169
+ setCurrentLanguageTag (props .context .pageContext .cultureInfo .currentUICultureName !== ' ' ?
170
+ props .context .pageContext .cultureInfo .currentUICultureName :
171
+ currentTermStoreInfo .defaultLanguageTag );
172
+ });
173
+ taxonomyService .getTermSetInfo (Guid .parse (props .termSetId ))
174
+ .then ((termSetInfo ) => {
175
+ setCurrentTermSetInfo (termSetInfo );
176
+ });
177
+ }, []);
178
+
179
+ < TaxonomyTree
180
+ languageTag = {currentLanguageTag }
181
+ onLoadMoreData = {taxonomyService.getTerms }
182
+ pageSize = {50 }
183
+ setTerms = {setTerms }
184
+ termSetInfo = {currentTermSetInfo }
185
+ termStoreInfo = {currentTermStoreInfo }
186
+ terms = {terms }
187
+ onRenderActionButton = {onRenderActionButton }
188
+ / >
189
+ ```
190
+
191
+ ![ ] ( https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/ModernTaxonomyPicker )
0 commit comments