You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Updated guidance on using JSOM to the latest version of SPFx
* Updated code sample in the guidance on validating web part property values
* Updated code samples in the guidance on using cascading dropdowns to the latest version of SPFx
* Updated guidance on building custom web part properties
Copy file name to clipboardExpand all lines: docs/spfx/web-parts/guidance/build-custom-property-pane-controls.md
+84-67Lines changed: 84 additions & 67 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# Build custom controls for the property pane
2
2
3
-
> Note. This article has not yet been verified with SPFx GA version, so you might have challenges on making this work as such with the latest release.
4
-
5
3
The SharePoint Framework contains a set of standard controls for the property pane. But sometimes you need additional functionality beyond the basic controls. You might need asynchronous updates to the data on a control, or a specific user interface. Build a custom control for the property pane to get the functionality you need.
6
4
7
5
In this article you will learn how to build a custom control for the property pane. You will build a custom dropdown control that loads its data asynchronously from an external service without blocking the user interface of the web part.
@@ -78,12 +76,12 @@ export default class ListItemsWebPart extends BaseClientSideWebPart<IListItemsWe
78
76
}
79
77
```
80
78
81
-
Update the **propertyPaneSettings**getter to:
79
+
Update the **getPropertyPaneConfiguration**method to:
The **IAsyncDropdownProps** class defines properties that can be set on the React component used by the custom property pane control. The **label** property specifies the label for the dropdown control. The function associated with the **loadOptions** delegate is called by the control to load the available options. The function associated with the **onChanged** delegate is called after the user selected an option in the dropdown. The **selectedKey** property specifies the selected value which can be a string or a number. The **disabled** property specifies if the dropdown control is disabled or not. The **stateKey** property is used to force the React component to re-render.
@@ -422,9 +441,9 @@ export class PropertyPaneAsyncDropdown implements IPropertyPaneField<IPropertyPa
422
441
423
442
The **PropertyPaneAsyncDropdown** class implements the standard SharePoint Framework **IPropertyPaneField** interface using the **IPropertyPaneAsyncDropdownProps** interface as a contract for its public properties that can be set from inside the web part. The class contains the following three public properties defined by the **IPropertyPaneField** interface:
424
443
425
-
***type**: Must be set to **PropertyPaneFieldType.Custom** for a custom property pane control.
426
-
***targetProperty**: Used to specify the name of the web part property to be used with the control.
427
-
***properties**: Used to define control-specific properties.
444
+
-**type**: Must be set to **PropertyPaneFieldType.Custom** for a custom property pane control.
445
+
-**targetProperty**: Used to specify the name of the web part property to be used with the control.
446
+
-**properties**: Used to define control-specific properties.
428
447
429
448
Notice how the **properties** property is of the internal **IPropertyPaneAsyncDropdownInternalProps** type rather than the public **IPropertyPaneAsyncDropdownProps** interface implemented by the class. This is on purpose so that the **properties** property can define the **onRender** method required by the SharePoint Framework. If the **onRender** method was a part of the public **IPropertyPaneAsyncDropdownProps** interface then, when using the asynchronous dropdown control in the web part, you would be required to assign a value to it inside the web part, which isn't desirable.
430
449
@@ -458,7 +477,7 @@ import { PropertyPaneAsyncDropdown } from '../../controls/PropertyPaneAsyncDropd
458
477
Then after that code, add a reference to the **IDropdownOption** interface and two helpers functions required to work with web part properties.
After selecting a list in the list dropdown, the selected value should be persisted in web part properties and the web part should be re-rendered to reflect the selected property.
509
528
510
-
#### Render the list web part property using the asynchronous dropdown property pane control
529
+
#### Render the list web part property using the asynchronous dropdown property pane control
511
530
512
-
In the **ListItemsWebPart** class change the **propertyPaneSettings**getter to use the asynchronous dropdown property pane control to render the **listName** web part property.
531
+
In the **ListItemsWebPart** class change the **getPropertyPaneConfiguration**method to use the asynchronous dropdown property pane control to render the **listName** web part property.
0 commit comments