Copied to clipboard

Flag this post as spam?

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


  • Arturo Soler 24 posts 77 karma points
    Aug 25, 2017 @ 10:21
    Arturo Soler
    0

    Enum DropDown Picker and custom Keys

    I am using nuPickers.Shared.EnumDataSource to set the key in an enumeration that I use in an "Enum DropDown Picker" editor.

     public enum PiwikSitios
     {
    [EnumDataSource(Label = "First option", Key ="1")]
    Option1,
    [EnumDataSource(Label = "Last option",Key ="2")]
     Option2
    }
    

    I expected that

    myPage.GetPropertyValue<Picker>(MyProp).PickedKeys.First() 
    

    returns "1" but returns "Option1".

    I have also tried with

    myPage.GetPropertyValue<Picker>(MyProp).AsEnums()
    

    But it returns a zero items collection.

    Any suggestion? (Versions Umbraco 7.6.4 nuPickers 1.7.0)

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 25, 2017 @ 10:39
    Dave Woestenborghs
    0

    Hi Arturo,

    I think you need to use this :

    myPage.GetPropertyValue<Picker>(MyProp).AsEnumes<PiwikSitios>()
    

    See the documentation : https://github.com/uComponents/nuPickers/wiki/Model#asenumst-and-asenums

    Dave

  • Arturo Soler 24 posts 77 karma points
    Aug 25, 2017 @ 10:54
    Arturo Soler
    0

    I had tried, but

    ? page.GetPropertyValue<Picker>(prop).AsEnums<PiwikSitios>().Count()
    

    returns 0

    While

    ? page.GetPropertyValue<Picker>(prop).PickedKeys.Count()
    

    returns 1.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 25, 2017 @ 11:00
    Dave Woestenborghs
    0

    Hmm,

    Strange. I just checked one of my projects and there this is working.

    Dave

  • Arturo Soler 24 posts 77 karma points
    Aug 25, 2017 @ 12:33
    Arturo Soler
    0

    Thank you, give hope, on Monday I will try some things.

  • Arturo Soler 24 posts 77 karma points
    Aug 28, 2017 @ 08:41
    Arturo Soler
    0

    Everything is working !. I even retrieve the key by directly using the PickedKeys property. The strange thing is that I have simply changed the storage format of the editor to JSON, then it has worked, I have returned to CSV, it was still working. I've probably triggered an update of the collection of keys somewhere.

Please Sign in or register to post replies

Write your reply to:

Draft