Copied to clipboard

Flag this post as spam?

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


  • Nathan 10 posts 80 karma points
    Apr 13, 2018 @ 06:50
    Nathan
    0

    New Dropdown in Umbraco 7.10.1

    Hi all, Where is the best way to get the value of new Dropdown in Umbraco 7.10.1 in Razor.

    It didn't found in Umbraco Documents

  • B. Gunnarsson (Bryns) 25 posts 180 karma points c-trib
    May 29, 2018 @ 14:57
    B. Gunnarsson (Bryns)
    0

    +1 trying to figure this out as well.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 29, 2018 @ 18:29
    Jan Skovgaard
    0

    Hi there

    How have you setup the dropdown in the Developer -> Datatypes section? And what does the razor code you have been trying to use for rendering the dropdown look like? And does it result in any kind of errors? If so please add it in here as it makes it a lot easier to help you out :-)

    Looking forward to hearing from you!

    /Jan

  • B. Gunnarsson (Bryns) 25 posts 180 karma points c-trib
    May 29, 2018 @ 19:27
    B. Gunnarsson (Bryns)
    0

    Hi Jan thanks for taking the time to check this out. I'm a front-end guy so these kind of things always get away from me if I can't find any documentation for it.

    I'm making a LeBlender control with a list of H1-H6 headings and this is the code that's fetching it:

    var heading = string.IsNullOrEmpty(item.GetValue<string>("size")) ? "h2" : UtilityService.GetPreValue(item.GetValue<string>("size")).ToLower();
    

    This returns empty. If I get the value straight from the "size" object I get this: [ "68" ]

    This is in an extension class which I can't remember where I got but have been using it with the old Umbraco.Dropdown with great success (pun intended):

    public static string GetPreValue(string id)
    {
    var value = string.Empty;
    
    if (!string.IsNullOrEmpty(id))
    {
        int preId = 0;
        var parse = Int32.TryParse(id, out preId);
    
        if (parse)
        {
            var helper = new UmbracoHelper(UmbracoContext.Current);
    
            value = helper.GetPreValueAsString(preId);
        }
    }
    return value;
    }
    

    Thanks again.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 29, 2018 @ 19:41
    Jan Skovgaard
    0

    Hmm, ok - I must confess that I have not really been using the grid and LeBlender so I'm currently a bit clueless here.

    Maybe I can try to recreate things on a clean install - But can you show me some screendumps of your LeBlender setup and Grid? That would probably help me...But I don't guarantee anything :-)

    /Jan

  • james 37 posts 121 karma points c-trib
    May 29, 2018 @ 21:12
    james
    1

    Hi Nathan, B,

    I've just written some documentation for the new dropdown property editor which is currently awaiting a review. In the meantime if you want to have a look at what I've written you can have a look at the draft here (there's a couple of brief code samples in there) but do bear in mind that this is unofficial until it's been reviewed and accepted.

    B, it looks like your GetPreValue method would work for the older Dropdown list, publishing keys property editor which saves IDs rather than values. The new dropdown property editor saves the selected value from the dropdown.

  • B. Gunnarsson (Bryns) 25 posts 180 karma points c-trib
    May 30, 2018 @ 09:57
    B. Gunnarsson (Bryns)
    0

    Hi James. Thanks for writing the documentation and providing us with the draft. I can see it's more or less like working with any property editor that returns a string.

    But my problem is that if I get it like this: (as in your first example)

    item.GetValue<string>("size")
    

    Then it returns like this:

    [ "68" ]
    

    but I want to get the "nice value" of "H1, H2" etc.

    Here are 2 screenshots of 1. The datatype I created for this purpose 2. The LeBlender control.

    Datatype

    LeBlender

  • Nathan 10 posts 80 karma points
    May 30, 2018 @ 10:02
    Nathan
    0

    Hi James, my problem like B. Gunnarsson's problem. When I use the new dropdown in LeBlender. And it return [ "68" ].

Please Sign in or register to post replies

Write your reply to:

Draft