This package has been flagged as retired by the package owner. Continue to use at your own risk
Provides a property value converter that creates a strongly typed model of the Umbraco grid and its controls/editors.
The base package (Our.Umbraco.GridValueConverters
) contains:
GridValueConverter
);GridControlConverter
for Grid.IControl
and GridEditorConverter
for Grid.IEditor
);GridControlsResolver
);GridControlAttribute
that can be applied to control classes and is used by default to specify for which grid editor alias or view the control must be resolved;ApplicationEventHandler
and GridWebBootManager
(the latter could be used when integrating to Umbraco core);HtmlGridControl
);The default package (Our.Umbraco.GridValueConverters.Default
) contains:
@Html.GetGridHtml()
).
This package is available as NuGet and Umbraco package. The recommended install method is NuGet:
PM> Install-Package Our.Umbraco.GridValueConverters
PM> Install-Package Our.Umbraco.GridValueConverters.Default
Explanation
The Umbraco grid property editor stores it's value/content in the database as JSON. The default (built-in) property value converter merges the saved JSON with the grid editor configuration (so it's always current) and returns a Newtonsoft.Json.Linq.JObject
.
After installing this package, the default property value converter is replaced/extended to return a Our.Umbraco.GridValueConverters.Models.Grid
. Nothing more, nothing less: now you're ready to use the strongly typed model - with autocomplete/IntelliSense - in your views... It's just like magic!
Well, actually not real magic:
Grid.IControl
types on application start and call IsControlEditor()
, untill it finds the specific type for the requested grid editor;Grid.Control
type has an implementation of the IsControlEditor()
method that checks for the GridControlAttribute
attribute and calls the IsControlEditor()
method of the attribute. This makes it possible to change this implementation in 2 different ways:
Grid.IControl
;Grid.Control
).To render rows and areas with optional settings (configuration/attributes and styles), to following helper can be used:
@using (Html.BeginGridTag(Grid.ISettings gridSettings, string tagName = "div", object htmlAttributes = null))
{
}
Using the same syntax, conditional tags can be rendered (if the condition is false, only the opening and closing tags will be omitted):
@using (Html.BeginTag(string tagName, bool condition = true, object htmlAttributes = null))
{
}
Grid controls are basically just partial views in a predefined folder (Views\Grid\Partials\Editors
). The partial view name, however, can be retrieved/inferred from the editors render
, view
or alias
properties (if not explicitly defined). The equivalents of @Html.Partial()
and Html.RenderPartial()
are:
@Html.GridControl(Grid.IControl gridControl, string partialViewName = null)
Html.RenderGridControl(Grid.IControl gridControl, string partialViewName = null)
Default grid controls
The default package includes views for rendering the 4 default frameworks (Bootstrap 2, Bootstrap 2 fuild, Bootstrap 3 and Bootstrap 3 fluid) and the following controls/editors:
EmbedGridControl
): embed HTML code;MacroGridControl
): the value contains the macro alias and parameters;MediaGridControl
): the value contains the image details (id, image URL, focal point, alternate text and caption) and the editor config the predefined image size. Also has methods to easily get the crop URL: GetCropUrl()
and GetCrop()
;RteGridControl
): HTML code with parsed internal links and resolved URLs;TextstringGridControl
): HTML encoded value with applied markup and styles from the editor config.