34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
@model Guid?
|
|
@{
|
|
string attributes = "class='form-control'";
|
|
if (ViewBag.Disabled == true)
|
|
{
|
|
attributes += " disabled='disabled'";
|
|
}
|
|
var dataSource = new Dictionary<KeyValuePair<Guid, string>, List<EnVisage.Models.CompanyModel>>();
|
|
if (null != (Dictionary<KeyValuePair<Guid, string>, List<EnVisage.Models.CompanyModel>>)ViewData["List"])
|
|
{
|
|
dataSource = (Dictionary<KeyValuePair<Guid, string>, List<EnVisage.Models.CompanyModel>>)ViewData["List"];
|
|
}
|
|
else
|
|
{
|
|
dataSource = EnVisage.Code.Utils.GetCompanies();
|
|
}
|
|
}
|
|
<select name="@Html.DisplayNameFor(t=>t)" id="@Html.IdFor(t=>t)" @(Html.Raw(attributes))>
|
|
@foreach (var item in dataSource)
|
|
{
|
|
if (!item.Value.Any())
|
|
{
|
|
<option value="@item.Key.Key" class="ddl-level-item">@item.Key.Value</option>
|
|
} else
|
|
{
|
|
<optgroup label="@item.Key.Value">
|
|
@foreach (var child in item.Value)
|
|
{
|
|
<option value="@child.Id" class="ddl-level-item pad-left" @(child.Id.Equals(Model) ? "selected" : "")>@child.Name</option>
|
|
}
|
|
</optgroup>
|
|
}
|
|
}
|
|
</select> |