Copied to clipboard

Flag this post as spam?

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


  • robert 3 posts 73 karma points
    Aug 11, 2016 @ 06:23
    robert
    0

    Dynamic DropDownList in Umbraco 7

    Hello Guys,

    How can i create a dynamic dropdown list in Umbraco 7. This dropdown items are going to populate through webservice.

    Please suggest a way through i can create a dynamic dropdownlist in Umbraco 7.

    Thanks Robert

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 11, 2016 @ 07:56
    Dan Diplo
    0

    Look at using a WebApi controller to return your data as JSON which you can query via JavaScript (eg. jQuery or whatever framework you like).

    Umbraco has it's own Web API controllers:

    https://our.umbraco.org/documentation/Reference/Routing/WebApi/

  • robert 3 posts 73 karma points
    Aug 11, 2016 @ 09:02
    robert
    0

    Hi Dan,

    Yes i understand that. But currently i am looking for a way to create the dropdown dynamically. I want to create my own datatype.

    {
    propertyEditors: [
        {
            alias: "YouTube.CategoriesList",
    
            name: "YouTube Categories List",
    
            editor: {
                view: "~/App_Plugins/YouTubeCategoryDDL/categoryDDL.html"
            }
        }
    ]   ,
       javascript: [
        "~/App_Plugins/YouTubeCategoryDDL/YouTubeCategories.controller.js"
    ]
    

    }

    Is this the right way?

    Thanks

  • David Hutson 48 posts 379 karma points
    Aug 11, 2016 @ 12:38
    David Hutson
    0

    You may not need to create a custom property editor.

    I have had great success with using nuPicker to create custom drop downs as it allows you write C# to surface the key value pair mappings.

    You just need to decide on what is the key and value are and it will work out of the box.

    Here is a great example of the power of using nuPicker with Flickr

    I hope this helps.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 11, 2016 @ 12:10
    Dan Diplo
    0

    Ahh, right, so you want a custom property editor with your dialogue. So, yes, you'd need to create an Angular JS view and controller for this. See https://our.umbraco.org/documentation/tutorials/Creating-a-Property-Editor/

    You can then use Angular to make an HTTP request to your web-service endpoint (if it returns JSON) or a WebApi controller that wraps your service (if it's SOAP). See https://docs.angularjs.org/api/ng/service/$http

    So you'd get back your data, create a select list - see https://docs.angularjs.org/api/ng/directive/ngOptions

Please Sign in or register to post replies

Write your reply to:

Draft