Saturday, June 19, 2021

Is it possible to connect two webpart in SPFx?

 Ans: Yes It is possible to create connected webparts in SPFx

Connecting web part using SPFx Dynamic Data is simple. Here are configuration/implementation steps:

  • In sender:
    • Implement IDynamicDataCallables interface in a web part with two methods: getPropertyDefinitions and getPropertyValue
    • Register a web part as a Data Source in onInit() method using this.context.dynamicDataSourceManager.initializeSource
    • Notify subscriber that some of properties have been changed using this.context.dynamicDataSourceManager.notifyPropertyChanged
  • In receiver:
    • Use this.context.dynamicDataProvider.registerAvailableSourcesChanged and this.context.dynamicDataProvider.getAvailableSources to iterate through available page's data source and select the ones to work with
    • Use this.context.dynamicDataProvider.registerPropertyChanged to register event handlers for specific data sources and properties

No comments:

Post a Comment