codepicker, a custom datatype

Rating: 4,5 / 5 stars - 4 vote(s).



I always wanted to replace to standard dropdown list by a more flexible solution, basically because I hate to type in all prevalues. I hate it because those lists might become gigantic in some situations. Imagine having to add more than 100 countries to a list from which a user should select a single one. Good luck, hire a jobstudent to do the job. Or, create a custom dropdownlist that can hold values populated from a datasource. I found some references in the code for v4 and started developing. I'm not going to go into much detail about the code, but here are the steps to install and use the codepicker custom datatype.

First, download the codepicker here. Next, copy the dll from the zip into the /bin folder of your umbraco installation.

Secondly, create a new table 'code_Country' in your database, holding two columns 'Id' (int) and 'Description' (varchar).

Enter a few records.

Next step: Go to the 'Developer' section, right-click on 'Data Types', and select 'Create'.

Add 'Country picker' and hit 'Create' again. Now, Select 'Country picker' from the tree, choose 'Code Picker' as Rendercontrol and select the table that holds the code values.

Hit the 'Save' button to persist the configuration for the 'Country Picker' custom data type.

Create a new document type ('Player' in screenshot) with a property of type 'Country Picker' and hit 'Save' button.

Next, create a document based on the document type you've just created.

'Country' dropdown list now holds all values you've previously entered in the database.

 

Currently, this custom 'Code Picker' data type is a pure SQL Server implementation. I'm planning to extend this functionality so it should be possible to get the code values from any custom datasource, whether MySql, Xml, Csv, ...

 

You may download the project file here.