Copied to clipboard

Flag this post as spam?

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


  • crono 58 posts 129 karma points
    Apr 21, 2015 @ 12:04
    crono
    0

    GetGridHtml in Controller

    Hi,

    Is it possible to render out a grid in a controller?

    I tried creating a new RenderModel, but GetGridHtml is nowhere to be found..

    Looking for something like this:

    var node = Umbraco.TypedContent(nodeId);
    var model = new Umbraco.Web.Models.RenderModel(node, System.Globalization.CultureInfo.CurrentUICulture); 
    var gridOutput = model.Content.GetGridHtml("gridAlias", "gridRenderer");
    

    I know I can just render out a view that calls the method, but that is not what I need, and i'd like to avoid having to make duplicate views.

    Basically I want to call a method in my controller that'll return a rendered grid.

    Thanks in advance :)

  • crono 58 posts 129 karma points
    Apr 21, 2015 @ 12:24
    crono
    0

    Just tried using:

    GridTemplateExtensions.GetGridHtml(node, "gridAlias", "gridRenderer");
    

    But it throws a null reference exception for Parametername: publishedContentRequest

    Can't seem to find anything related to the grid when searching for that =/

    Any ideas?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Apr 21, 2015 @ 12:41
    Jeroen Breuer
    0

    Hello,

    What happens when you try the following?

    using Umbraco.Web;

    var node = Umbraco.TypedContent(nodeId);
    var html = node.GetGridHtml("gridAlias", "gridRenderer");

    Jeroen

  • crono 58 posts 129 karma points
    Apr 21, 2015 @ 12:48
    crono
    0

    Hi Jeroen,

    Thanks for chiming in..

    Same thing happens, null reference exception for Parametername: publishedContentRequest

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Apr 21, 2015 @ 12:52
    Jeroen Breuer
    0

    Hmm in that case it might be better to check how it works in the sourcecode: https://github.com/umbraco/Umbraco-CMS/blob/ded1def8e2e7ea1a4fd0f849cc7a3f1f97cd8242/src/Umbraco.Web/GridTemplateExtensions.cs.

    Jeroen

  • crono 58 posts 129 karma points
    Apr 21, 2015 @ 14:11
    crono
    0

    Thanks for the link Jeroen,

    Doesn't seem to be much I can do with that extension, besides what is already being done above..

    I might just end up creating a separate renderview instead.

  • Jonathan Roberts 409 posts 1063 karma points
    Jun 27, 2017 @ 15:22
    Jonathan Roberts
    0

    Hi, Did you manage to create your own RenderView?

    Jon

Please Sign in or register to post replies

Write your reply to:

Draft