src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/TemplateChooser.cshtml

(完整代码) 1KB

@using Easy.ViewPort.Descriptor
@model Object
@{
    Style.Reqiured("select2").AtHead();
    Script.Reqiured("select2").AtFoot();

    var descriptor = ViewData.ModelMetadata.GetViewDescriptor() as DropDownListDescriptor;

    Dictionary<string, string> options = new Dictionary<string, string>();
    if (Model != null)
    {
        options.Add(Model.ToString(), Model.ToString());
    }
    if (descriptor != null)
    {
        if (descriptor.SourceType == SourceType.ViewData)
        {
            foreach (var item in ViewData[descriptor.SourceKey] as SelectList)
            {
                options[item.Value] = item.Text;
            }
        }
        else
        {
            foreach (var item in descriptor.OptionItems)
            {
                options[item.Key] = item.Value;
            }
        }
    }
}
@Html.DropDownList("", new SelectList(options,"Key","Value"), descriptor?.ToHtmlProperties())

@using (Script.AtFoot())
{
    <script type="text/javascript">
        $(function () {
            $("#@Html.Id("")").select2({ tags: true });
        });
    </script>
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。