Copied to clipboard

Flag this post as spam?

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


  • Davide 4 posts 73 karma points
    Dec 11, 2017 @ 09:56
    Davide
    0

    Create a new data type without using angularjs

    Hello everyone, I'm new to umbraco and I was wondering is there possibility to create a new data type without having to use angularjs? Thank you all for the availability

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Dec 11, 2017 @ 21:55
    Alex Skrypnyk
    0

    Hi Davide

    Did you mean "property editor"?

    Umbraco version 7 works only with angular property editors.

    Thanks,

    Alex

  • Davide 4 posts 73 karma points
    Dec 12, 2017 @ 08:01
    Davide
    0

    Hi Alex, I have to create a specific property editor for an entity of MD CRM, just not knowing angularjs I was wondering if it was possible to create a new property editor without using angularjs.

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Dec 12, 2017 @ 08:20
    David Brendel
    1

    Hi Davide,

    you can create Property Editors with C# code. It basically is a class which inherits from PropertyEditor class and has an Attribute on it like this:

    [PropertyEditor("EventCalendar.CalendarPicker", "EventCalendar CalendarPicker", "dropdown", IsParameterEditor = true, ValueType = "int")]
    public class CalendarPickerPropertyEditor : PropertyEditor
    

    Hope that gets you started.

    Regards David

  • Davide 4 posts 73 karma points
    Dec 12, 2017 @ 08:37
    Davide
    0

    hello David, as I said I'm not a maximum of umbraco and its operation, you would have a simple example to show me so as to try to create a simple property editor. Thank you for your availability

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Dec 15, 2017 @ 09:12
    David Brendel
    0

    Hi Davide,

    as said there is not much to do. The attribute: [PropertyEditor("EventCalendar.CalendarPicker", "EventCalendar CalendarPicker", "dropdown", IsParameterEditor = true, ValueType = "int")]

    The properties are the alias of the editor, the display name, the type of the editor; in this case a dropdown - could also be datetimepicker or something else. IsParameterEditor specifies if the editor can also be used in macros and ValueType which value is returned.

    If you just want to provide a property editor with no custom logic than you don't have anything to do besides the attribute and inheriting the class.

    If you need custom logic then you can override the method "CreateValueEditor". In that method you can for example gather custom data which you want to show in a dropdown. In my case a have a list of "calendar" which I want to make selectable in the dropdown which then looks like this:

    var dictionary = new Dictionary<int, string>();
                dictionary.Add(0, "All calendar");
                calendar.ToList().ForEach(c => dictionary.Add(c.Id, c.Name));
                base.DefaultPreValues.Add("items", dictionary);
                var preValues = calendar.Select(x => new PreValue(x.Id, x.Name)).ToList();
                preValues.Insert(0, new PreValue(0, "All calendar"));
                editor.ConfigureForDisplay(new PreValueCollection(preValues));
    

    But that of course depends on what type of data you want to handle. Have a look at the properties which are available and the methods. It's mostly trial & error.

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft