0

I want to connect to the document library built in web part in SharePoint online and programmatically change the document library name from another web part. is There anyway to do that? web part

2 Answers2

0

You cannot rename the built-in web parts, if this is what you mean.

Nikolay
  • 10,752
  • 2
  • 23
  • 51
  • i want to configure the library name property dynamically with no need to edit page and edit web part. – Mahmoud Samy Dec 17 '20 at 11:06
  • Still not quite clear. There are "default web part settings" for this, maybe this is what you mean? You can put those in the webpart's manifest, in the "properties" section. Or you mean you want to set another webpart's (that is already on the page) property? – Nikolay Dec 17 '20 at 11:58
  • here is the required scenario i want to list the document libraries in the site select one and explore the content to create folder and files and so on – Mahmoud Samy Dec 17 '20 at 12:03
  • Can't you just use file browser control for this? https://pnp.github.io/sp-dev-fx-property-controls/controls/PropertyFieldFilePicker/ – Nikolay Dec 17 '20 at 12:39
0

@Mahmoud Samy,

I understand you're developing a custom SPFx web part. In this webpart you want to change the embed library in a built-in document library webpart in a modern page. If so, you could have a try PnPjs:

 // use from the sp.web fluent chain
  const page = await sp.web.loadClientsidePage("/sites/tcccc/SitePages/ssssss.aspx");
  let control = page.findControl(c => c['title'] == 'Document library') as ClientsideWebpart; 
  control.setProperties(
    {
      hideCommandBar: true,
      isDocumentLibrary: true,
      selectedListId: "bb30a1a4-c5fd-4cc5-a8cc-b3c0163f5555",
      selectedListUrl: "/sites/tcccc/SiteAssets",
      selectedViewId: "1419b89f-e56f-4337-9028-3f33560c59fc",
      webRelativeListUrl: "/SiteAssets"
    }
  );

  control.data.webPartData.serverProcessedContent.searchablePlainTexts= {listTitle: "Site Assets"};       
  page.save();

More reference:

Baker_Kong
  • 1,739
  • 1
  • 4
  • 9