Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Mar 27, 2015 @ 10:36
    Martin
    0

    Grid Partial - Row Name as class

    Hi,

    Im looking for some help with the grid partial view. I would like to add the row name as a class in the partial.

    I can get the rowName in the cfg attrs, but it outputs in all properties.

    Any help or ideas would be grateful

    Martin

    @functions {
        public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
        {
            var attrs = new List<string>();
    
            var rowName = contentItem.name;
    
            JObject cfg = contentItem.config;
    
            if(cfg != null)
                foreach (JProperty property in cfg.Properties()) {
                    attrs.Add(property.Name + "=\"" + rowName + 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));
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft