Stacy K. Basye
Stacy K. Basye

Reputation: 117

Using Umbraco 7.2 grid view, how do I insert the grid view into my template?

I'd really like to use grid view to render my content on a simple text page. I've got a grid view with the alias "content" set up. What do I type in the template to get it to show up? @CurrentPage.content does not work. I realize it probably uses those partials that 7.2 came with but I've got no idea how to use them.

It may help to know my knowledge level on this. I'm very new at wiring up templates to doctypes. The only ways of pulling data from my content I actually know how to use so far are these:

Upvotes: 2

Views: 4787

Answers (2)

Stacy K. Basye
Stacy K. Basye

Reputation: 117

The answer was to insert this into the template:

@CurrentPage.GetGridHtml("propertyalias")

In my case, content would go in place of propertyalias.

Upvotes: 1

ProNotion
ProNotion

Reputation: 3692

Official documentation for the GridView can be found on the community website. For posterity's sake here is the relevant part:

Render grid in template

To display the grid on a site use:

@CurrentPage.GetGridHtml("propertyAlias")

This will by default use the view /views/partials/grid/bootstrap3.cshtml you can also use the built-in bootstrap2.cshtml view by overloading the method:

@CurrentPage.GetGridHtml("propertyAlias", "bootstrap2")

or point it a custom view, which by default looks in /views/partials/grid/ - or provide the method with a full path

@CurrentPage.GetGridHtml("propertyAlias", "mycustomview")
@CurrentPage.GetGridHtml("propertyAlias", "/views/mycustomfile.cshtml")

If you're working with a strongly typed model simply replace @CurrentPage with @Model.Content, so:

@Model.Content.GetGridHtml("propertyAlias")

Upvotes: 11

Related Questions