Code Monkey home page Code Monkey logo

Comments (6)

patrick-rodgers avatar patrick-rodgers commented on May 29, 2024

What part is not working above? When you say same behavior, can you be more specific there are several things in the thread you linked. Thanks!

from pnpjs.

Sartor87 avatar Sartor87 commented on May 29, 2024

It is a custom web part - for the sake of simplicity I've created an OOB HelloWorld web part.

The web part is successfully found from the web part definitions and built with the code

helloWorldPoCPart = ClientSideWebpart.fromComponentDef(helloWorldPoCDef[0]);

However, when I add it to the page, it is rendered as a blank web part:
https://user-images.githubusercontent.com/23637375/36662564-aa582f8e-1ad6-11e8-8193-20ed1bead0c2.PNG

According to the discussions in the linked bug, I have modified the Component's ID without brackets. Note that I've tried both with the original definition (with brackets) and without brackets.

image

UPDATE 1: I've modified the ClientSidePageComponent object's Id property with toLowerCase() and it now appears. For now, I've implemented a method which fixes the Id of the web part

from pnpjs.

patrick-rodgers avatar patrick-rodgers commented on May 29, 2024

So the guid from your custom component definition contains capital letters, meaning the id is as well. When you make them lower-case it then works? Can you share the code that "fixes" the issue? I'd like to get this resolved in the library if possible.

from pnpjs.

Sartor87 avatar Sartor87 commented on May 29, 2024

Sure, it is quick and dirty code, but here it is:

`
// code within another method
someMethod(): void {
const partDefs: ClientSidePageComponent[] = await sp.web.getClientSideWebParts();
const helloWorldPoCDef: ClientSidePageComponent[] = partDefs.filter(c => c.Name === "HelloWorld");
let fixWebPart: ClientSidePageComponent = this.fixClientSideWebPart(helloWorldPoCDef[0]);
let helloWorldPoC: ClientSideWebpart = ClientSideWebpart.fromComponentDef(fixWebPart);
}

private fixClientSideWebPart(webpart: ClientSidePageComponent): ClientSidePageComponent {
let fixedWebPartDefinition: ClientSidePageComponent = webpart;
fixedWebPartDefinition.Id = webpart.Id.replace("{", "").replace("}", "").toLowerCase();
console.log("ID set: " + fixedWebPartDefinition.Id);
return fixedWebPartDefinition;
}
`
I was thinking to match the id of the ClientSidePageComponent object with the ClientSidePageComponent -> manifest object (needs JSON.parse though)

from pnpjs.

patrick-rodgers avatar patrick-rodgers commented on May 29, 2024

I can inside of the fromComponentDef method make these adjustments when I set the id. So perhaps that will be enough. Thanks for sharing the code.

from pnpjs.

github-actions avatar github-actions commented on May 29, 2024

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.

from pnpjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.