Copied to clipboard

Flag this post as spam?

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


  • stephen 83 posts 124 karma points
    Sep 03, 2018 @ 18:24
    stephen
    0

    Grid in a Partial View

    All the documentation seems to suggest displaying the grid content via a Template but is there a way to display the content within a Partial View?

    I have tried something like this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Test>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @Html.GetGridHtml(Model.Content, "propertyAlias")
    

    but I get Object Reference not set...etc

    I can use

    @Umbraco.Field("fieldname")
    

    which returns json, but that's not really helpful.

    It works fine in the Master template, but that's not much use either.

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Sep 04, 2018 @ 12:54
    Paul Seal
    101

    Hi From a partial view, you can access the Grid like this:

    @Html.GetGridHtml(Umbraco.AssignedContentItem, "propertyAlias")
    

    Kind regards

    Paul

  • IsabelChristensen 5 posts 35 karma points
    Mar 16, 2020 @ 10:24
    IsabelChristensen
    0

    Hey Paul, I have some problem finding my property alias for my grid. My first guess would be "text" - see picture below.

    enter image description here

    But that didn't work. Afterwards I look up in the Data type and type "columns" that didn't work either.

    enter image description here

    So i am lost?

  • stephen 83 posts 124 karma points
    Sep 04, 2018 @ 14:32
    stephen
    0

    Worked. Many thanks!

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Sep 07, 2018 @ 12:44
    Paul Seal
    0

    You're welcome, please mark the solution so people know it is solved.

    Kind regards

    Paul

Please Sign in or register to post replies

Write your reply to:

Draft