- 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.
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.
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.
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 @.
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,
@Model.Content.GetGridHtml("bodyText") works - I'm still confused about the difference between Model.Content and CurrentPage.
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
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
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?
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 @.
is working on a reply...