Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 430 posts 1023 karma points
    Sep 07, 2017 @ 22:32
    Ayo Adesina
    0

    Umbraco.DropDown - Set the selected value in custom Angular View (custom back office section)

    Hi Guys I am reusing the 'Umbraco.DropDown' property editor in my custom angular view I am using the directives like this:

                            <umb-property property="campaignTypePropertyEditor">
                                <umb-editor model="campaignTypePropertyEditor"></umb-editor>
                            </umb-property>
    

    and this is what I am passing in:`

    campaignTypePropertyEditor = {
                editor: "Umbraco.DropDown",
                label: label,
                description: description,
                hideLabel: false,
                view: "dropdown",
                alias: alias,
                value: 1,
                validation: {
                    mandatory: true,
                    pattern: ""
                },
                config: {
                    items: [
                        { id: "0", value: "Option1""},
                        { id: "1", value: "Option2" },
                        { id: "3", value: "Option3" }
    
                    ],
    
                }
            };
    

    How do I set which item is selected? I have tried setting value to 1 (above) expecting Option 2 to be selected but when the page loads the items are present but none of them are selected.

    I have seen this post:

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/81580-custom-section-reuse-datatype-dropdownlist

    but the solution invloves changing the Angular View but in my case I want to reuse the umbraco's view and don't want to change this file.

    So how do I:

    Select the option that I want selected when the page loads, without making changings to the HTML in the property editor.

  • Ayo Adesina 430 posts 1023 karma points
    Sep 08, 2017 @ 06:50
    Ayo Adesina
    0

    I have been trying to work this out for hours..... maybe I will have to make my own version of the property editor, then I can change the HTML with out worrying.... it must be possible as umbraco does it.....

    any other suggestions?

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Sep 08, 2017 @ 08:13
    Kevin Jump
    0

    Hi

    it could be a type thing ?

    looking at the code for the dropdownlist - this should work - as it does

    ng-model="model.value"
    ng-options="item.id as item.value for item in model.config.items"
    

    looking at the code above - your value is

    value: 1 
    

    and your items are

    { id: "1", value: "Option 2" }
    

    so model.value is an int and the item.id is a string - It doesn't always make a difference but it might in this case?

  • Ayo Adesina 430 posts 1023 karma points
    Sep 08, 2017 @ 09:29
    Ayo Adesina
    0

    I tried changing

    value: 1
    

    to

    value:"1"
    

    Still doesn't work

    Really ripping my hair out now.

Please Sign in or register to post replies

Write your reply to:

Draft