PerplexDigital / Perplex.ContentBlocks

Block based content editor for Umbraco
MIT License
31 stars 15 forks source link

How we use Grid option inside and render value using default @Html.GetGridHtml(Model.Content, "columns") #29

Closed pankajinfo3 closed 4 years ago

pankajinfo3 commented 4 years ago

How we use Grid option inside and render value using default @Html.GetGridHtml(Model.Content, "columns")

PerplexDaniel commented 4 years ago

Are you using a doctype with a Grid property as a ContentBlock? I imagine that should work as usual. In your code example, is Model an IContentBlockViewModel<T>, where T is your doctype? What is the output of @Html.GetGridHtml() in your example?

pankajinfo3 commented 4 years ago

cannot convert from 'Perplex.ContentBlocks.Rendering.IContentBlockViewModel' to 'Umbraco.Core.Models.PublishedContent.IPublishedProperty'

@Html.GetGridHtml(Model, "columnsbuilder")

I am using this way code

pankajinfo3 commented 4 years ago

I do this code GridValue grid = JsonConvert.DeserializeObject(Model.Content.Value("columnsbuilder").ToString()); to get Grid

PerplexDaniel commented 4 years ago

@Html.GetGridHtml should be called on IPublishedContent or IPublishedProperty, so you should call with Model.Content, right? Model is indeed the IContentBlockViewModel so that won't work.

What's the output of @Html.GetGridHtml(Model.Content, "columnsbuilder")?

PerplexDaniel commented 4 years ago

I do this code GridValue grid = JsonConvert.DeserializeObject(Model.Content.Value("columnsbuilder").ToString()); to get Grid

Do you want the HTML or the JSON? This code you give will just give you the JSON right? Regardless, anything you do should work the same as on a "normal" Umbraco doctype, as you should be getting the same ModelsBuilder object.

pankajinfo3 commented 4 years ago

I need HTML

pankajinfo3 commented 4 years ago

image

PerplexDaniel commented 4 years ago

Ah I see, it does not work on IPublishedElement, that's interesting.

Anyway, try this to use the overload with an IPublishedProperty:

@Html.GetGridHtml(Model.Content.GetProperty("columnsbuilder"))

pankajinfo3 commented 4 years ago

wooowww nice it's work :) thanks

pankajinfo3 commented 4 years ago

also how i add language that manage by Dictionary created control

PerplexDaniel commented 4 years ago

also how i add language that manage by Dictionary created control

Not sure what you mean by this, but perhaps you can create a new issue for this one and provide some example code. I'll close this one now as it's resolved.

pankajinfo3 commented 4 years ago

Thanks