Dynamically loading data to dropdown from Umbraco backoffice content

Hi folks,

Recently I came across a problem while developing a website using Umbraco.  which is I need to load the drop down values in the umbraco backoffice content using the content defined in same/other backoffice content.

Usually  if we want to have custom valued dropdown list, we’ll create a new dropdown datatype with custom dropdown list values. But it has some limitation, such as;

  1. Need to create multiple dropdown datatype if the site supports multiple languages.
  2. It’s too complected for the end used to create new dropdown type and adding it to document type.

so the easy solution will be, allow the user to set the dropdown values via umbraco backoffice content.

for example: the user able to define the job types in the content and the job types should be shown in some other content page as drop down values..

Define the dropdown values
in

Show the dropdown values

out

Let’s start the work;

first we need to create a custom data type that loads the dropdown data dynamically.

create a class by extending AbstractDataEditor

The method “GetJobDropdownDataList(parentNode.Id)” used to get the dropdown values from its parent node which need to show with dropdown box.

Now you will see the data “Dynamic job data dropdown” as Property editor when creating new data type under developer panel.

datatype1

Now you can use the “ddlJobEducation” data type when creating Documents type.

dataobj

 

Happy Blogging with Umbraco 🙂

You may also like...

1 Response

  1. Hannah says:

    How would to dynamically set a dropdown. e.g if creating a new article how would you set the dropdown to a specific value.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: