Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
80 lines (74 sloc) 3.48 KB
@model Object
@using MvcControlsToolkit.Core.Templates
@using MvcControlsToolkit.Core.Views
@{
var metaData = ViewData.ModelMetadata;
var col = ViewData["Options"] as Column;
var modelName = ViewData.TemplateInfo.HtmlFieldPrefix;
}
@if (col.ColumnConnection != null)
{
if (col.ColumnConnection.QueryDisplay)
{
<input asp-for="@Model" placeholder="@col.PlaceHolder" class="@(!string.IsNullOrEmpty(col.InputDetailCssClass) ? col.InputDetailCssClass : "form-control")" />
<span data-valmsg-for="@modelName" data-valmsg-replace="true" class="text-danger"></span>
}
else if (col.ColumnConnection is ColumnConnectionInfosStatic)
{
var infos = col.ColumnConnection as ColumnConnectionInfosStatic;
var items = await infos.GetItems(Context.RequestServices, User);
<select asp-for="@Model" asp-items="@(new SelectList(items, infos.ItemsValueProperty, infos.ItemsDisplayProperty))"
class="@(!string.IsNullOrEmpty(col.InputDetailCssClass) ? col.InputDetailCssClass : "form-control")">
@if (col.PlaceHolder != null)
{
<option value="">@col.PlaceHolder</option>
}
</select>
<span data-valmsg-for="@modelName" data-valmsg-replace="true" class="text-danger"></span>
}
else
{
var infos = col.ColumnConnection as ColumnConnectionInfosOnLine;
var provider = infos.SuggestionsProvider(Context.RequestServices);
<autocomplete for-explorer="@ViewData.ModelExplorer.GetExplorerForProperty(col.For.Name)"
display-explorer="@ViewData.ModelExplorer.GetExplorerForProperty(infos.DisplayProperty.Name)"
for-expression-override="@col.For.Name"
display-expression-override="@infos.DisplayProperty.Name"
items-display-property="@infos.ItemsDisplayProperty"
items-value-property="@infos.ItemsValueProperty"
items-url="@provider.GetDisplayValueSuggestionsUrl(Url)"
url-token="@provider.DisplayValueSuggestionsUrlToken"
dataset-name="@infos.DataSetName"
max-results="@infos.MaxResults"
partial-selection="true"
class="@(!string.IsNullOrEmpty(col.InputDetailCssClass) ? col.InputDetailCssClass : "form-control")" />
}
}
else if (metaData.UnderlyingOrModelType == typeof(bool))
{
<p @Html.Raw("class='" + (col.CheckboxDetailCssClass != null ? col.CheckboxDetailCssClass : "form-control-static") + "'")>
@if (Model != null && ((bool)Model))
{
<input name="@modelName" checked="checked" type="checkbox" />
}
else
{
<input name="@modelName" type="checkbox" />
}
</p>
}
else if (metaData.IsEnum)
{
<select asp-for="@Model" asp-items="@Html.GetEnumSelectList(metaData.ModelType)" class="@(!string.IsNullOrEmpty(col.InputDetailCssClass) ? col.InputDetailCssClass : "form-control")">
@if (col.PlaceHolder != null)
{
<option value="">@col.PlaceHolder</option>
}
</select>
<span data-valmsg-for="@modelName" data-valmsg-replace="true" class="text-danger"></span>
}
else
{
<input asp-for="@Model" placeholder="@col.PlaceHolder" class="@(!string.IsNullOrEmpty(col.InputDetailCssClass) ? col.InputDetailCssClass : "form-control")" />
<span data-valmsg-for="@modelName" data-valmsg-replace="true" class="text-danger"></span>
}