Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Nov 27, 2015 @ 17:53
    Ismail Mayat
    0

    Passing data from view to doctype grid editor view

    Using Umbraco 7.2.8 and I have a view and I want to pass some data down the the doc type grid partial, so in my main template I have:

      @Model.Content.GetGridHtml("mainContentGrid", "contentGrid", new ViewDataDictionary { { "currentProduct", productModel } })
    

    Then in my view for the grid component partial

    var productModel = (ProductModel) ViewData["currentProduct"];
    

    however that is always null. Is this even possible if not then how do i do it?

    Regards

    Ismail

  • James Wilkinson 15 posts 72 karma points c-trib
    Nov 29, 2015 @ 11:29
    James Wilkinson
    0

    Hi Ismail,

    I'm doing something similar, but am passing the data from the grid partial into the grid editor;

    @Html.Partial("grid/editors/base", (object)control, new ViewDataDictionary { { "css", "mega-menu" } })
    

    Then in the grid editor I use ViewBag to get at the data:

    @ViewBag.css
    

    I'm not sure if this is best practice, but it's working for me :)

    Cheers,

    James

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Nov 30, 2015 @ 09:49
    Ismail Mayat
    0

    James,

    I have what i need to pass in my main view i tried passing through using viewdata but no joy. For now just to get things working i use session feels dirty as hell but works.

    Must be a better way.

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft