New in JUNO, Data Editor Settings

Friday, October 29, 2010 by Tim Geyssens

As you may know, the main focus for Umbraco Juno is the starter kits and skinning (so aimed at making it easier to get started with Umbraco), if you're a seasoned Umbraco developer you'll most likely start with a clean Umbraco installation (and don't care that much about the starter kits).But we're also introducing a new developer feature in Juno, that should make one of the more difficult items in Umbraco  a lot easier!

Creating custom datatypes

Creating your own data types is very easy when using the usercontrol wrapper method but once you want custom settings you won't be able to do that using the usercontrol wrapper but instead you'll need a custom data editor and for settings you'll need to create a custom prevalue editor class which is basically a custom control that allows you to setup the settings for a data type. 

Introducing data editor settings

By using the new DataEditorSetting attribute you'll be able to dynamically generate the data type settings editor, eliminating the need for a custom prevalue editor class.

100 lines of code reduced to 2

The data editor settings should be a huge time saver for Umbraco devs since there is no more need to create a custom prevalue editor class anymore (and taking care of the whole crud of the settings), but it's just a matter of adding a property on your AbstractDataEditor and marking that with the DataEditorSetting attribute.

Sample:

[DataEditorSetting("Limit", description = "Maximum number of characters")]
public string Limit { get; set; }

Will result in this (if you don't specify the type a text field will be used):

image 

So the custom prevalue editor class (which is easily around 100 lines of code) is simply replaced by a property and an attribute, it's that easy!

Also no more need to figure out how to use content pickers, media pickers, … Since its a breeze to use them, simply set the type to the one you want to use

[DataEditorSetting("Content picker demo",
            type = " umbraco.editorControls.SettingControls.Pickers.Content,  umbraco.editorControls",
            description = "content picker")]
        public string TestContentPicker { get; set; }

Result:

image

21 Default data editor setting types

If you don't specify the type a simple text field will be used, but there are 20 other controls available out of the box.

  • Checkbox
  • Checkbox list
  • Content Picker
  • Content Picker with XPath option
  • Date picker
  • Date picker with time
  • Dropdown list
  • Document type picker
  • Field picker
  • List box (select single item)
  • List box multiple (select multiple items)
  • Media picker
  • Media type picker
  • Member group picker
  • Member type picker
  • Path picker
  • Password
  • Radio button list
  • Text area
  • Values

And how they look:

image

This should cover all of the common controls used in the data type editor and of course it's possible to extend Umbraco and create your own custom data editor settings types.

Default values

It's also possible to provide a default value, by simply supplying the defaultValue param in the attribute

[DataEditorSetting("Limit", description = "Maximum number of characters", defaultValue = "500")]
public string Limit { get; set; }

Want to give it a try? Download the latest nightly build of Juno.

13 comment(s) for “New in JUNO, Data Editor Settings”

  1. Gravatar ImageNik Says:

    This is simply marvelous! Nice work as usual guys.

  2. Gravatar ImageLee Kelleher Says:

    Excellent! I am looking forward to integrating this within uComponents!

  3. Gravatar ImageMorten Bock Sørensen Says:

    Very nice. Will make it much easier to do more advanced datatypes.

  4. Gravatar ImageLeon Says:

    Nice work. Just one comment, is it worth adding a known enum for common umbraco property types such as the content picker so we don't have to go searching for the fully qualified name?

  5. Gravatar ImageMatt Brailsford Says:

    This sounds amazing!

    Will this be extendable so you can embed custom controls?

  6. Gravatar ImageAaron Powell Says:

    Wouldn't it be better to pass in the type reference than the string of the type property?

    so you'd do:
    [DataEditorSettings("Content Picker Demo", type=typeof( umbraco.editorControls.SettingControls.Pickers.Content))]

    It would mean that you're not getting runtime errors by miss-spelling the type name. You also don't have to worry about dynamically assembly loading based on a string.

  7. Gravatar ImageHartvig Says:

    @Aaron: Brilliant idea!

  8. Gravatar ImageTim Geyssens Says:

    @Matt, absolutely!

    @Aaron, good point, will update

  9. Gravatar ImageLee Says:

    This looks amazing :) Will all this new stuff be covered on Umbraco.tv?

  10. Gravatar ImageTim Geyssens Says:

    @Lee, yup we'll update the data editors chapter with some vids on this new feature

  11. Gravatar ImageTom Maton Says:

    This is fantastic guys!!

    Keep up the great work

  12. Gravatar ImageFredrik Sewén Says:

    Just tested this in the new Juno Beta release! Fantastic, it's soo nice! Keep it up!

  13. Gravatar ImageGiedrius Says:

    Hey,

    is it possible to achieve effect as "Mysql insert to db" statement?
    I have a .net usercontrol to extract data from DB and display in content page, but i also need a usercontrol for inserting data from back-end of umbraco. Will "June" help me at this point?

Leave a comment