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
    Jul 29, 2014 @ 16:02
    Martin
    0

    Trouble With Razor Values in U7 Data Grid

    Hi, I'm having trouble with pulling the individual values from the data grid. I can get the full string with both label and value, but i'm new to razor and having trouble.

    @widget.featureBlock gives me everything within the datatype.

    [ { "blockTitle": "Feature Block 1", "blockParagraph": "Feature Block 1 Content", "blockIcon": "1094", "urlPicker": "1062" }, { "blockTitle": "Feature Block 2", "blockParagraph": "feature Block 2 Content", "blockIcon": "1095", "urlPicker": "1054" } ]

    My razor macro is

    @{
        var widgetsFolder = Model.WidgetsFolders.Where("Visible").First();
    }
    
    @foreach (dynamic widget in widgetsFolder.Children.Where("Visible and nodeTypeAlias.StartsWith(\"Widget_\")")) {
    
        string widgetType = widget.NodeTypeAlias.ToString();
    
        switch (widgetType) {
            case "Widget_FeatureBlocksReveal":
            @showFeatureBlocksReveal(widget);
            break;
            default:
                <b>Unknown Widget!</b>
                break;
        }
    
    }
    
    @helper showFeatureBlocksReveal(dynamic widget){
    
    
        if (!string.IsNullOrEmpty(widget.featureBlock.ToString()))
        {
            foreach(dynamic content in widget.featureBlock)
            {
                @content.blockTitle
            }
        }   
    }
    

    Any help would be grateful.

    Martin

Please Sign in or register to post replies

Write your reply to:

Draft