Code Monkey home page Code Monkey logo

Comments (6)

raymondlittle100 avatar raymondlittle100 commented on June 11, 2024 1

Updated to version 1.0.4 and was able to set the dataVersion to 1.2 and this worked. I'll keep an eye out for the full fix so I can remove the hard coded version

from pnpjs.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

Just looked into this and I am not sure how to "fix" it. The dataVersion doesn't appear to come back with the definition, at least I don't see it (please tell me if I missed it) - meaning I don't know how to set it to anything other than the 1.0 default. We aren't setting the value from the definition - and this reminds me why.

When I do this (I made a property public to do it) it works how you want:

const partDefs = await sp.web.getClientSideWebParts();

const yy = partDefs.filter(d => d.Id.startsWith("7f7184"));

const part = ClientSideWebpart.fromComponentDef(yy[0]);

part.setProperties({
    layout: 2,
    persons: [{
        id: "i:0#.f|membership|[email protected]",
    }],
});
// FORCE dataVersion
part.dataVersion = "1.2";

const page = await ClientSidePage.fromFile(sp.web.getFileByServerRelativeUrl("/sites/dev/sitepages/Test_8q5L.aspx"));

page.addSection().addControl(part);

await page.save();

So changing the dataVersion DOES fix the issue. Now here is the problem, I have no idea how to know what to set to the dataVersion to. In this case 1.2 works - but I can't tie that to anything solid to handle this automatically. Not saying it can't be done - but I haven't found it yet. This one remains open for now.

from pnpjs.

raymondlittle100 avatar raymondlittle100 commented on June 11, 2024

Thanks for the update it certainly is a strange one. Just to check are you planning on exposing the dataVersion property so this can be updated?

from pnpjs.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

It is already, you can use to get around the protected bit.

(<any>part).dataVersion = "1.2";

And in the next version it will be public. I am also adding code to read the value from the webpart markup when it comes in.

from pnpjs.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

Going to close this as blocked and I don't see any plans to address this on the product side. We can revisit if/when updates are made on the server. Thanks!

from pnpjs.

github-actions avatar github-actions commented on June 11, 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.