Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 16, 2015 @ 21:13
    Chriztian Steinmeier
    0

    How to set nuPickers property value from code?

    Hi all,

    I have a points property on a Task doctype set up as a nuPickers.XmlRadioButtonPicker, saving as XML.

    I'm trying to set the value of this from code, using something like this:

    var newTask = contentService.CreateContent("Task Title", newCard.Id, "Task");
    if (newTask != null) {
      newTask.SetValue("points", 13);
      contentService.SaveAndPublishWithStatus(newTask);
    }
    

    This actually saves, and the property is saved as "13", but it's not displaying correctly in the Backoffice, because it's supposed to store a chunk of XML instead, akin to this:

    <points>
      <Picker>
        <Picked Key="5">13</Picked>
      </Picker>
    </points>
    

    How do I correctly save a "picked" value to a property?

    /Chriztian

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 17, 2015 @ 06:32
    Dave Woestenborghs
    0

    Hi Chriztian,

    I think nuPickers stores it value in a specific format.

    Maybe you can use the steps in this article to save your data.

    http://24days.in/umbraco/2014/working-with-complex-archetype-datatypes/

    This article is about archetype, but I think the same principle would apply to nuPickers as well.

    Dave

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 17, 2015 @ 06:40
    Chriztian Steinmeier
    0

    Hi Dave,

    Thanks - and I think you're totally right - I've verified that "just" saving the XML I know has to go there works, but I hope I can get my head around using the Property Editor Value Converter (or something similar) to do the dirty work of looking the value up and serializing it properly. That way it should continue to work if someone decides to change the data type from saving as XML, to say, JSON in the future... (I guess :-)

    /Chriztian

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 17, 2015 @ 06:43
    Dave Woestenborghs
    0

    Yeah...who uses XML and XSLT anyway :-)

    Dave

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 17, 2015 @ 06:46
    Chriztian Steinmeier
    0

    Yeah...who uses XML and XSLT anyway :-)

    I do!! :-)

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 17, 2015 @ 06:47
    Dave Woestenborghs
    0

    Really...never would have guessed that :-p

Please Sign in or register to post replies

Write your reply to:

Draft