Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 08, 2016 @ 10:39
    Ismail Mayat
    0

    Grid background image on row

    Hello,

    I have setup two properties in settings for my grid namely:

    Settings
    Class

    Styles Background image

    The class one has json config looks like:

    [ { "label": "Class", "description": "Set a css class", "key": "class", "view": "textstring" } ]

    For the styles one i have:

    [ { "label": "Set a background image", "description": "Set a row background", "key": "background-image", "view": "imagepicker", "modifier": "url({0})" } ]

    Both properties work fine so i can pick a style class for row and set a background image.

    The issue is in my ContentGrid.cshtml file I have:

    public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
    {
        var attrs = new List<string>();
        JObject cfg = contentItem.config;
    
        if(cfg != null)
            foreach (JProperty property in cfg.Properties()) {
                attrs.Add(property.Name + "='" + property.Value.ToString() + "'");
            }
    
        JObject style = contentItem.styles;
    
        if (style != null) { 
        var cssVals = new List<string>();
        foreach (JProperty property in style.Properties())
            cssVals.Add(property.Name + ":" + property.Value.ToString() + ";");
    
        if (cssVals.Any())
            attrs.Add("style='" + string.Join(" ", cssVals) + "'");
        }
    
        return new MvcHtmlString(string.Join(" ", attrs));
    }
    

    Issue is i do not see my background image property on the config object. Am I missing something? I need to get this background image that has been set.

    Regards

    Ismail

  • David Peck 690 posts 1896 karma points c-trib
    Aug 08, 2016 @ 11:18
    David Peck
    0

    That's all just straight out of the box stuff right? It looks correct to me!

    Do you get the same whether applied to the cell or the row?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 08, 2016 @ 11:47
    Ismail Mayat
    0

    David,

    It is all out of the box. Only tested on the row, the class works fine but background image is not present in the config. However in content section it is definately saved.

    Regards

    Ismail

  • David Peck 690 posts 1896 karma points c-trib
    Aug 08, 2016 @ 12:15
    David Peck
    0

    I'd suggest it could be the hyphen in the background-image, but I'm sure that would have been reported as a bug.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 08, 2016 @ 12:21
    Ismail Mayat
    0

    David,

    It's an epic fail on my part. This is multilingual site and i was setting in once place but viewing somewhere else GRRRRR.

    My bad.

    Regards

    Ismail

  • David Peck 690 posts 1896 karma points c-trib
    Aug 10, 2016 @ 08:44
    David Peck
    0

    It's good to know that this happens to other people to.

Please Sign in or register to post replies

Write your reply to:

Draft