Copied to clipboard

Flag this post as spam?

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


  • aleksandar 14 posts 74 karma points
    Sep 28, 2015 @ 12:19
    aleksandar
    0

    Set.value in multi node tree picker

    Hi does anyone know the data saving format for multi ndoe tree picker, i have problem when i want to programaticly set new value, not chosing from the umbraco cms.

  • Kevin Jump 2341 posts 14868 karma points MVP 8x c-trib
    Sep 29, 2015 @ 19:07
    Kevin Jump
    0

    Hi

    The MNTP values should just be a comma separated list of NodeIds, i.e

    1032,1042,1039

    If you have you're content item , its stored as a string, so you should beable to call

    item.SetValue("yourMNTPpropertyAlias", nodelist)
    

    remember to save the via the contentService.

  • David Armitage 508 posts 2078 karma points
    May 22, 2018 @ 05:18
    David Armitage
    9

    Hi Guys,

    Its got a little more complicated recently. I miss the days when you could just pass in a list of Ids.

    Unfortunately you now have to pass in a list of UDIs. This is a combination of some document stuff and a formatted guid.

    A valid example would look something like this.

    string selectedItems = "umb://document/217f4677b69140958c8951eb3d3638f9,umb://document/d44a409e4f14416fb862356dd38cc7ac,umb://document/52595f172a934995ab0935087a012c6b"
    

    I used to generate the UDI manually by getting the node key(guid) and building up the string. Fortunately a recently found an easier way to generate this key.

    IPublishedContent node;
    string UDI = Udi.Create(Constants.UdiEntityType.Document, node.GetKey()).ToString();
    

    Hope this helps someone.

    Kind Regards

    David

  • Saif Obeidat 79 posts 296 karma points
    Apr 16, 2019 @ 13:04
    Saif Obeidat
    1

    Do you have any idea if it has been changed in Umbraco 8 as well?

  • Bjørn Nyborg 5 posts 73 karma points
    Sep 07, 2020 @ 19:25
    Bjørn Nyborg
    0

    You can do it in a similar way in Umbraco 8, make sure that you use a real GuidUdi by creating it with a new GuidUdi()

    In this case i have a string[] with the ID's of the nodes. I can save these to a multinode treepicker by doing this:

    var selected = signUpData.Selected.Select(x => new GuidUdi("document", Umbraco.Content(x).Key).ToString()).ToArray();
    content.SetValue("selected", string.Join(",", selected));
    

    Another example could be something like:

    string[] selected = new string[] { new GuidUdi("document", Umbraco.Content("1234").Key).ToString() };
    content.SetValue("selected", string.Join(",", selected));
    
Please Sign in or register to post replies

Write your reply to:

Draft