Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DotNet Dropdown Picker - Only render keys, how to render values #200

Open
oliverEvry opened this issue Dec 18, 2019 · 0 comments
Open

DotNet Dropdown Picker - Only render keys, how to render values #200

oliverEvry opened this issue Dec 18, 2019 · 0 comments

Comments

@oliverEvry
Copy link

Hi!

I'm running Umbraco 7.15.3 together with NuPicker 1.7. where I have DotNet Dropdown looking like this:

`public class LanguagesDotNetDataSource : IDotNetDataSource
{
IEnumerable<KeyValuePair<string, string>> IDotNetDataSource.GetEditorDataItems(int contextId)
{
var languages = ["sv-se", "en-gb"];
var list = new List<KeyValuePair<string, string>>();
for (int i = 0; i < languages.Length; i++)
{
list.Add(new KeyValuePair<string, string>(i.ToString(), languages[i]));
}

    if (list.Count < 1)
    {
        list.Add(new KeyValuePair<string, string>("1", "en-gb"));
    }
    return list;
}

}`

https://github.com/uComponents/nuPickers/wiki/Data-Source-DotNet

Everything works fine in Umbraco backoffice showing a dropdown with "sv-se", "en-gb" and so on but when I´m trying to get the actual value in a view I just get the keys.

Getting them:

var picker = fileNode.GetPropertyValue<Picker>("nuPickerPropertyName");

this returns a picker with both the picked keys and the saved value showing 0 for the first item in the dropdown, 1 for the second and so on. If i try to get the values using :

picker.AsPublishedContent();

the result is null.

https://github.com/uComponents/nuPickers/wiki/Model#helper-methods

/Oliver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant