Copied to clipboard

Flag this post as spam?

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


  • Thomas Hansen 72 posts 253 karma points
    Mar 13, 2019 @ 20:52
    Thomas Hansen
    0

    Render Grid

    Hey,

    I have some problem rendering the grid in Umbraco 8. I only have the basic out of the box from Umbraco.

    I'm using Modelbuilder.

    This is the error i'm getting

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedModels.Home' does not contain a definition for 'sections'
    

    * The error is "Model.sections in the bootstap3.cshtml file" *

    @if (Model != null && Model.sections != null)
    {
    var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
    
    <div class="umb-grid">
        @if (oneColumn)
        {
            foreach (var section in Model.sections) {
                <div class="grid-section">
                    @foreach (var row in section.rows) {
                        @renderRow(row);
                    }
                </div>
            }   
        }else { 
            <div class="row clearfix">
                @foreach (var s in Model.sections) {
                    <div class="grid-section">
                        <div class="col-md-@s.grid column">
                            @foreach (var row in s.rows) {
                                @renderRow(row);
                            }
                        </div>
                    </div>
                }
            </div>
        }
    </div>
    }
    

    Markup

    @Html.GetGridHtml(Model, "gridContent", "bootstrap3");
    

    What am I doing wrong ?

  • Thomas Hansen 72 posts 253 karma points
    Mar 15, 2019 @ 14:15
    Thomas Hansen
    0

    Anyone ? :)

  • Ikunato 8 posts 109 karma points
    Mar 15, 2019 @ 14:27
    Ikunato
    100

    This sounds like a dumb question (because I think I have approximately the same amound of knowledge as you) but what is the content of this grid ?

    I have the exact same content of your pages and this work with me...

    Also, in VS you can add a breakpoint in the Bootstrap3.cshtml, put one and check if your "Model" have "sections"

  • Frans de Jong 462 posts 1585 karma points c-trib
    Mar 15, 2019 @ 16:39
    Frans de Jong
    1

    Did you make a typo in the property alias?

  • Thomas Hansen 72 posts 253 karma points
    Mar 18, 2019 @ 19:03
    Thomas Hansen
    0

    Sorry for the late reply.

    I found the error.. really stupid one.. I testet it on the english langauge layer.. But added the content to the danish layer.. :P

    Need to wired my head around for Umbraco 8 :D !

Please Sign in or register to post replies

Write your reply to:

Draft