Skip to content

Instantly share code, notes, and snippets.

@skttl
Created February 6, 2019 10:10
Show Gist options
  • Save skttl/b28277e50a10fb410bbd48e55dcc843a to your computer and use it in GitHub Desktop.
Save skttl/b28277e50a10fb410bbd48e55dcc843a to your computer and use it in GitHub Desktop.
Partial view for rendering Doc Type Grid Editor content using Skybrud.Umbraco.GridData
@using Our.Umbraco.DocTypeGridEditor.Helpers
@using Our.Umbraco.DocTypeGridEditor.Web.Extensions
@inherits UmbracoViewPage<GridControl>
@*
This view converts the dynamic Doc Type Grid Editor model to the parts needed for firing up the view
for DTGE based editors. It then uses DTGEs own methods for rendering the needed partial views.
We could do a strongly typed edition of this, but since this is a one-off and we probably never have
to edit this particular view, we didn't.
*@
@{
var model = (dynamic)Model.JObject;
if (model.value != null)
{
string id = model.value.id.ToString();
string editorAlias = model.editor.alias.ToString();
string contentTypeAlias = "";
string value = model.value.value.ToString();
string viewPath = model.editor.config.viewPath.ToString();
try
{
contentTypeAlias = model.value.dtgeContentTypeAlias.ToString();
}
catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException)
{
contentTypeAlias = model.value.docType.ToString();
}
if (contentTypeAlias != "")
{
var content = DocTypeGridEditorHelper.ConvertValueToContent(id, contentTypeAlias, value);
@Html.RenderDocTypeGridEditorItem(content, editorAlias, viewPath)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment