Copied to clipboard

Flag this post as spam?

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


  • Rob Gibson 13 posts 94 karma points
    Oct 21, 2014 @ 20:14
    Rob Gibson
    1

    Grid in 7.2: Row with Partial View content?

    Hello,

    This is my first post, so let me say thank you for your contributions to Umbraco, I greatly appreciate it. I am writing to see if anyone knows of a good way that I could define a grid row to dynamic content defined in a partial view. Basically I want to render an inline ad in the middle of articles depending on tags defined in that articles meta data.

    I do not want to allow content editors to choose many details about the ad beyond the categories of the article, which will reference categories defined for the ads. I am really pleased with the grid system, but I'm having a hard time placing how to perform this task. I would like to give them a row option of "inline ad" that does not have any additional editing functionality besides drag/drop/delete. Right now the ads are rendered as part of a partial view called from my templates, but if I really need it to be inserted into the grid itself.

    Guidance requested, thanks a ton, you're my heroes.

    Rob

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Oct 22, 2014 @ 08:23
    Dave Woestenborghs
    102

    Maybe you can create a macro and let the user add a macro to the grid. This is already supported in the default grid that comes with the install.

    Another way is to create your own editor for the grid. If you look at the umbraco source code you can find it in https://github.com/umbraco/Umbraco-CMS/tree/7.2.0/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors

    This will give you a good idea on how to create your own angular based editor

    You will also need to add your editor to the grid config found in : /config/grid.editors.config.js

    And next you need to create a MVC view for rendering your grid. Examples can be found in the folder /Views/Partials/Grid/Editors

    Dave

  • Rob Gibson 13 posts 94 karma points
    Oct 22, 2014 @ 16:11
    Rob Gibson
    0

    Thanks for getting back to me. Before your reply, I ended up creating my own editor which appears to work, though I would note for anyone doing the same you need to add the editor to  /config/grid.editors.config.js  as well as making the partial view

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Newtonsoft.Json.Linq.JObject>

    so that it can render it on the grid designer.

    A change I would suggest is that if a row can only contain one type of element, that it automatically be populated with such an element when the row is created. That would allow for a smoother workflow for some operations, while maintaining the flexibility the system already has.

    Rob

Please Sign in or register to post replies

Write your reply to:

Draft