Aug 12 2019 04:58 AM
Dear Experts,
I am struggling to fulfil my requirement is that, I need to create modern SharePoint client webpart (Spfx)
Which renders the list of all webpart, that exists in the current page.
Can anybody helps me out regarding he same.
Thanks
Asesh
Aug 12 2019 06:19 AM
@Asesh Kumar Maity The easiest method would be to use PnPJs Client-side page functionality. Check out the section on "Find Controls"
https://pnp.github.io/pnpjs/sp/docs/client-side-pages/
Aug 12 2019 06:26 AM
Is this pnpjs abblicable to classic sharepoint page in online?
Means if I create a SPfx webpart using the pnp, is it valid in Classic SharePoint Page.
Thanks
Nov 23 2019 05:39 AM
no, you can't use in classic page.
btw, you can get all spfx webpart in a moder page using this method.
It require PnP/PnPJs
public async GetAllWebpart(): Promise<any[]> {
// page file
const file = sp.web.getFileByServerRelativePath(this.context.pageContext.site.serverRequestPath);
const page = await ClientSidePage.fromFile(file);
const wpData: any[] = [];
page.sections.forEach(section => {
section.columns.forEach(column => {
column.controls.forEach(control => {
var wp = { text: control.data.webPartData.title, key: control.data.webPartData.instanceId };
wpData.push(wp);
});
});
});
return wpData;
}
Cheers,
Federico
Feb 10 2020 12:26 AM