Copied to clipboard

Flag this post as spam?

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


  • CoolKiwiBloke 12 posts 51 karma points
    Dec 17, 2014 @ 02:56
    CoolKiwiBloke
    0

    Cannot Render Grid

    Hi,

    I followed the instructions here http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/built-in-property-editors-v7/grid-layout

    - I created a grid datatype
    - I created a document type with a grid property called bodyText
    - I created a grid template which includes the line @CurrentPage.GetGridHtml("bodyText")
    - I create a page based on the grid document type and created a grid and added data to it

    And yet nothing is showing when I display the page. I'm new to Umbraco so probably missing something obvious. If someone could please suggest what else I can check/change.

    As a test I put @Umbraco.Field("bodyText") in my template and sure enough it renders the JSON OK.

    Thanks,

  • CoolKiwiBloke 12 posts 51 karma points
    Dec 17, 2014 @ 05:35
    CoolKiwiBloke
    0

    @Model.Content.GetGridHtml("bodyText") works - I'm still confused about the difference between Model.Content and CurrentPage.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 17, 2014 @ 08:21
    Dennis Aaen
    0

    Hi CoolKiwiBloke,

    Back when I was starting looking at Razor I was a bit confused about the difference between Model.Content and CurrentPage too. But the CurrentPage, is the dynamic version of Razor, while Model.Content is a strongly typed version of Razor.

    If you see the documentation for the media picker for Umbraco 7 http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Media-Picker you can see there is a typed version, and a dynamic version. Here are some MVC Razor Cheatsheets, so you can see the difference between the dynamic razor and strongly typed razor. http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets. I know this says for Umbraco 6, but you can use this in Umbraco 7 too.

    Hope this helps,

    /Dennis

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 17, 2014 @ 08:33
    Dave Woestenborghs
    0

    I would recommend using the strongly typed version (@Model,Content) for several reasons.

    - If you use Visual Studio you will have intellisense
    - Also the dynamic version (@CurrentPage) get's parsed and uses the strongly typed version under the hood, so you will get a little overhead in rendering because of this parsing
    - If you are filtering lists with complex Where clauses this can have a performance hit when using the dynamic version.

    Dave 

  • CoolKiwiBloke 12 posts 51 karma points
    Dec 17, 2014 @ 08:52
    CoolKiwiBloke
    0

    Thanks guys... certainly shines some light on things... I'll get there :)

    Still seems to me odd that @CurrentPage.GetGridHtml("bodyText") didn't work though?

  • Steve Morgan 1349 posts 4458 karma points c-trib
    Jan 13, 2015 @ 17:38
    Steve Morgan
    0

    I've just had a few shouts at this.. I think it's to do with Razor. 

    If you're in "Code mode" where you'd normally omit the "@" it doesn't seem to work but adding the output @ symbol fixes this!?  

    Is this something to do with the GetGridHtml method and how it "echos" out to the template? Either way if you've landed here wondering why GetGridHtml() isn't working for you try adding / removing the preceding @.

Please Sign in or register to post replies

Write your reply to:

Draft