Copied to clipboard

Flag this post as spam?

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


  • Gerry Smith 13 posts 73 karma points
    Dec 18, 2015 @ 16:20
    Gerry Smith
    0

    Grid JSON question

    We have an Umbraco site that was created years ago, v4.x era. It's a beast (~4000 nodes). We're now on 7.3.1, having updated it over time to try to keep current.

    As you might guess by the age of the site, it's set up for WebForms. I'm in the process of rewriting >100 usercontrols and XSLT macros into partial view macros.

    So, now I want to implement the Grid Editor. I followed some instructions found here on Our forums. Everything appears to be working in the backoffice, but on the front side, the editors don't render, they just display the JSON.

    Image:Example

    What am I doing wrong/incompletely?

    Thank you for helping!

  • Mike Chambers 3 posts 72 karma points
    Dec 18, 2015 @ 18:12
    Mike Chambers
    0

    @Umbraco.Field("gridParamName") will give you the json...

    @Model.GetGridHtml("gridParamName") will give you the rendered output...

  • Yasir Butt 161 posts 371 karma points
    Dec 18, 2015 @ 18:55
    Yasir Butt
    100

    Hi,

    Are you using Model.Content.GetPropertyValue("yourgridproperty")?

    For grid you have to use Model.Content.GetGridHtml("yourgrid")

    Yasir

  • Gerry Smith 13 posts 73 karma points
    Dec 18, 2015 @ 19:13
    Gerry Smith
    0

    Hi Yasir,

    I'm not... the templates on our site are still Masterpages. In the Doctype for this page, I replaced the RTE datatype for bodyText with a Grid Editor, still named bodyText. It's then referenced in the Masterpage/template like this:

    <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
    

    I tried replacing that line with

    @Model.Content.GetPropertyValue("bodyText") 
    

    But that simply renders the text "@Model.Content.GetPropertyValue("bodyText") " .

    I also tried putting the site into Mvc mode (versus Webforms mode), no change.

    I appreciate you helping, I'm sure it's something small I'm missing.

  • Yasir Butt 161 posts 371 karma points
    Dec 18, 2015 @ 19:26
    Yasir Butt
    0

    Not sure about web form! any way Have you tried this Model.Content.GetGridHtml("yourgrid")?

  • Gerry Smith 13 posts 73 karma points
    Dec 18, 2015 @ 19:31
    Gerry Smith
    0

    I did, without success. I also made a new Template, Razor this time, and assigned the document to use it.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    
    Model.Content.GetPropertyValue("bodyText");  //Tried both of these, one at a time
    Model.Content.GetGridHtml("bodyText");
    
    }
    <p>Hello World!
    

    Only "Hello World!" is rendered.

  • Yasir Butt 161 posts 371 karma points
    Dec 18, 2015 @ 19:37
    Yasir Butt
    0

    hmm!

    i am only using MVC so thats why not sure about webforms

    but i saw the same problem here

    https://our.umbraco.org/forum/templating/templates-and-document-types/61222-Render-grid-layout-using-the-WebForms

    Do you have below structure in your webforms? enter image description here

    In mvc we have grid renderer template which used to render content from grid.

    Yasir

  • Gerry Smith 13 posts 73 karma points
    Dec 18, 2015 @ 19:44
    Gerry Smith
    0

    No... it doesnt seem that Webforms and/or Masterpages is goign to work for the Grid.

    I did get it to work though...

    1. Set site mode to Mvc
    2. Create razor view template (rather than Masterpage).
    3. In the Razor template:
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{ }
    @CurrentPage.GetGridHtml("bodyText");
    

    Note that this is the same as your idea, but syntax for DynamicContent...

    Now I just need to convert my enormous Masterpage templates to Views.

    Thanks for your help Yasir, you led me right to the answer!

    Gerry

  • Yasir Butt 161 posts 371 karma points
    Dec 18, 2015 @ 19:51
    Yasir Butt
    0

    Its good that you got it working and now you are on a right track :)

  • Ian 178 posts 752 karma points
    Dec 18, 2015 @ 23:25
    Ian
    0

    If you still want to use masterpages could you not just create a partial view macro and put your razor GetGridHtml code into that then use the old school <umbraco:Macro Alias=".." runat="server"></umbraco:Macro>

    I used to mix webforms and MVC this way until I was ready to switch everything to MVC and it worked fine.

  • Gerry Smith 13 posts 73 karma points
    Dec 20, 2015 @ 00:25
    Gerry Smith
    0

    Great idea, Ian. Seems like I tried something similar originally, but I know I wasnt doing it right (the specific call to the Grid Editor). Your suggestion seems like a safer short-term solution with respect to my overlords freaking out on changes that can actually be seen ;)

    Thanks!

    Gerry

Please Sign in or register to post replies

Write your reply to:

Draft