SharePoint/PnP-JS-Core

Selecting the document library that will be listed in a webpart using sp-pnp-js

Closed this issue · 3 comments

Category
[ ] Enhancement

[ ] Bug

[X] Question

Version
Please specify what version of the library you are using: [ 3.0.7]

Expected / Desired Behavior / Question
I have added the webpart "Document library (preview)" to a page using sp-pnp-js.

Can I select which document library that will be listed in that webpart using sp-pnp-js or do I have to go and edit that page and select the document library manually?

I´m using this as an example: https://github.com/SharePoint/PnP-JS-Core/wiki/Working-With:-Client-side-Pages

For all of these web parts you need to use the "setProperties" method to set the properties. We have created interface definitions for a couple - but haven't had a chance to do them all. The easiest way to see what the properties should look like is to add one to a page, load it from JS, and see the format ot the properties object. If you figure out the format for other parts would love for you to share them back so we can add to the set of interfaces we have defined.

part.setProperties<any>({
    // some properties for the document library web part
});

If you are just getting started with the pnp libraries would encourage you to check out the new versions with all the same capabilities and more.

Thanks! I managed to select the library using:

part.propertieJson.isDocumentLibrary = true;
part.propertieJson.listTitle,
part.propertieJson.selectedListId,
part.propertieJson.selectedListUrl,
part.propertieJson.selectedViewId,
part.propertieJson.webpartHeightKey

I loaded an existing page with a webpart that had a list selected and checked the properties for that webpart.

Thanks!