Copied to clipboard

Flag this post as spam?

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


  • Bo Jacobsen 438 posts 1818 karma points
    Jul 10, 2018 @ 20:25
    Bo Jacobsen
    0

    Rendering grid editor content as C# object instead of dynamic

    Hi all.

    Is it possible to use MyCustomModel instead of a dynamic when rendering grid editor content?

    Taken from build-your-own-grid-edior, Model would look like this.

    {
        "value": "What ever value entered into the textarea",
        "editor": {
            "name": "Code",
            "alias": "code",
            "view": "/app_plugins/yourpackage/editor.html",
            "icon": "icon-code",
            "config": {
                    "color": "red",
                    "text-align": "right"
                }
    }
    

    Should my model inherit from something?

    public class MyCustomModel
    {
        [JsonProperty("value")]
        public string Value { get; set; }
    
        // GridEditor is a custom object containing name,alias,view,icon and config.
        [JsonProperty("editor")]
        public GridEditor Editor { get; set; }
    }
    

    So i can use this?

    // This
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
    
    // To
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<MyCustomModel>
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies