Introduction
In this article, you will learn the basics of creating a custom pane property definition. This helps with adding pane properties to the web part property panes using web part files.
In my previous articles, you can learn about adding existing properties to SPFx web part properties pane.
- Customizing SharePoint Framework Web Part Properties - Part One
- Customizing SharePoint Framework Web Part Properties - Part Two
- Customizing SharePoint Framework Web Part Properties - Part Three
- Customizing SharePoint Framework Web Part Properties - Part Four
- Customizing SharePoint Framework Web Part Properties - Part Five
So far, you have seen only adding/using property templates available on open source. Now, you will learn developing and inserting custom pane properties to the properties pane.
The custom field property declared in the web part file (under getPropertyPaneConfiguration method) contains target property name and other custom properties.
- PropertyFieldMessageBar('targetpropname', customprops)
In the below sections, you will see in detail about the pane property definition for the custom pane property declared above.
Interfaces Available
Microsoft provides two interfaces for creating custom property.
- IPropertyPaneCustomFieldProps
This interface provides key properties and methods that help in developing the pane property. Properties and methods available are the following. - context
- key
- onDispose() and
- onRender()
- IPropertyPaneField
This interface provides a few properties that can be inherited for defining the custom pane property (fields). - properties
- shouldFocus
- targetProperty - Property name
- type - Type of property (custom, text, dropdown, etc.)
Developing the Property Definition File
The property definition is written as a function which inherits data from class and interface components. Here, a custom interface is introduced to input the user defined custom properties. The properties like label, on property change method and other internal properties are defined here.
The following code snippet shows the sample custom interface defined to input from the user. Likewise, any other properties can be defined.
- interface IPropertyFieldMessageBarProps {
- label: string;
- onPropertyChange(propertyPath: string, oldValue: any, newValue: any): void;
- properties: any;
- key?: string;
- }
Note - The values are declared and passed when the property is declared in the getPropertyPaneConfiguration method of the web part file.
Then another interface is defined which inherits properties from IPropertyPaneCustomFieldProps. This is an internal interface that contains all the properties and methods, which will not be exposed to users or the web part file. This can, in turn, hold the properties collection (created using previous interface IPropertyFieldMessageBarProps) as one property.
The following snapshot shows the sample internal interface, which is not exposed to users or web part file.

mayur sorathiyaPosted Sep 4, 2019, 6:27 AM
How to implement SharePoint custom property Pen with angular 2+?