Copied to clipboard

Flag this post as spam?

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


  • fabbau 18 posts 108 karma points
    Feb 19, 2020 @ 17:17
    fabbau
    0

    Access nested Grid content

    Hi all,

    I have a element type which includes a Grid property like shown in the screenshot below: enter image description here

    With a nested DataType property I implemented this element in a template like so: enter image description here

    In the template, I grab the content of this item.

    var steps = Model.Value<IEnumerable<IPublishedElement>>("step", fallback: Fallback.ToAncestors);
    

    Then I loop over it:

    foreach (var step in steps)
    {
       var stepDetailsAccordionId = "accordion-item" + Guid.NewGuid().ToString();
       var stepIcon = step.Value<IPublishedContent>("stepIcon");
       var stepHeader = Html.Raw(step.Value("stepHeader").ToString());
       var stepDetailsHead = Html.Raw(step.Value("stepDetailsHead").ToString());
       var stepDetailsGrid = step.Value<IEnumerable<IPublishedElement>>("stepDetailsGrid");
       @* Html.GetGridHtml(Umbraco.AssignedContentItem, "stepDetailsGrid", "Bootstrap3-Fluid");*@
       var stepDetailsEnd = Html.Raw(step.Value("stepDetailsEnd").ToString());
    

    Now I don't know how to access this item.

    When i try to loop over it:

    foreach (var stepGrid in stepDetailsGrid)
    {
        Html.GetGridHtml(Umbraco.AssignedContentItem, "grid", "Bootstrap3-Fluid");
    }
    

    I get a "NullReferenceException" error for the "stepDetailsGrid"

  • fabbau 18 posts 108 karma points
    Feb 20, 2020 @ 13:52
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies