Copied to clipboard

Flag this post as spam?

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


  • Stefaan Christiaens 5 posts 116 karma points
    Sep 30, 2015 @ 16:25
    Stefaan Christiaens
    0

    Umbraco Grid custom editor not persisting config to the Model

    I am trying to implement a custom Umbraco Grid editor for a fixed widht and height image. The config in /config/grid.editors.config.js now looks like this:

    [
    {
        "name": "Image",
        "alias": "media",
        "view": "media",
        "icon": "icon-picture"
    },
    ... other default editors 
    {
        "name": "Fixed width image",
        "alias": "fixedwidthimage",
        "view": "media",
        "icon": "icon-picture",
        "config": {
            "size": {
                "width": 170,
                "height": 300
            }
        }
    }
    ]
    

    With this in place (see the last grid editor: Fixed width image), I can select it in the grid. Everything also persists to the view. The problem is that I cannot get to the config part. It always comes up empty:

    if (Model.editor.config != null && Model.editor.config.size != null)
    {
        url += "?width=" + Model.editor.config.size.width;
        url += "&height=" + Model.editor.config.size.height;
    
        if (Model.value.focalPoint != null)
        {
            url += "&center=" + Model.value.focalPoint.top + "," + Model.value.focalPoint.left;
            url += "&mode=crop";
        }
    }
    

    Mdodel.editor is not null and shows the correct custom editor I added in the config. But Model.editor.config is {} when evaluating the dynamic expression in Visual Studio.

    Additional information: I did not do anything else then add the editor in the config as depicted above to get the custom editor working in Umbraco.

    Thank you guys in advance!

  • Stefaan Christiaens 5 posts 116 karma points
    Oct 01, 2015 @ 09:13
    Stefaan Christiaens
    101

    OK, I fixed it.

    It just so happened that the config was added after I added an item with that editor to the grid.

    So, in short, always create the config before editing the grid.

Please Sign in or register to post replies

Write your reply to:

Draft