Copied to clipboard

Flag this post as spam?

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


  • schlubadub 102 posts 617 karma points
    Nov 12, 2015 @ 14:06
    schlubadub
    0

    Access row / cell settings from control

    Is there a way to access the Grid row or cell settings from within a child control (partial or LeBlender)? I would even settle for being able to access the row name that the control is in.

    I can already do this inside the Grid template (e.g. Fanoe.cshtml) but I want to access it at the control level for the container that it's in. I have already setup the grid settings to be applied at the row and cell level, I just don't know how to tap into it or if it's even possible.

    Essentially, I want to have a carousel control adjust the height/width of the images based on grid cell setting (e.g. a class or id), or even on a pre-defined row name. It sounds like it should be fairly straightforward, but I'm struggling to find the right method to access it.

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Nov 14, 2015 @ 09:23
    Marc Goodson
    0

    Hi schlubadub

    In the 'framework' rendering file (the default one is bootstrap3.cshtml in /views/partials/grid) , you can see a foreach loop that loops through each row, and calls 'renderRow'. It's possible to update this file on your project.. to check the name of the row being rendered and do something different:

    @foreach (var row in s.rows) {
    if (row.Name == "Product Row"){
     @doCrazyProductRowRendering(row);
    }
    else {
    //default row render 
     @renderRow(row, false);
     }
    }
    

    However maybe from what you are saying above, it might be worth investigating Anders' Skybrud.Umbraco.GridData package:

    https://our.umbraco.org/projects/developer-tools/skybrudumbracogriddata/

    and

    https://github.com/skybrud/Skybrud.Umbraco.GridData

    this package enables you to get a strongly typed model of the grid data eg:

    GridDataModel grid = Model.Content.GetPropertyValue<GridDataModel>("body");
    

    if that helps...

Please Sign in or register to post replies

Write your reply to:

Draft