Пример #1
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 combobox 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 cbo 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString ComboBox(this HtmlHelper htmlHelper, string exp, ComboBoxSettings settings = null, object htmlAttributes = null)
        {
            var builder = new EasyUITagBuilder("select", "easyui-combobox", settings);

            builder.MergeAttribute("name", exp);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.GenerateId("cbo" + exp);
            return(new ExtendHtmlString(builder));
        }
Пример #2
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 timespinner 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static HtmlString TimeSpinner(this HtmlHelper htmlHelper, string exp, TimeSpinnerSettings settings = null)
        {
            var builder = new EasyUITagBuilder("input", "easyui-timespinner", settings);

            builder.MergeAttribute("name", exp);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-input");
            builder.GenerateId("txt" + exp);
            return(new HtmlString(builder.ToString(TagRenderMode.Normal)));
        }
Пример #3
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 datetimespinner 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString DateTimeSpinner(this HtmlHelper htmlHelper, string exp, DateTimeSpinnerSettings settings = null)
        {
            settings = settings ?? new DateTimeSpinnerSettings();

            var builder = new EasyUITagBuilder("input", "easyui-timespinner", settings);
            builder.MergeAttribute("name", exp);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-input");
            builder.GenerateId("txt" + exp);
            return new ExtendHtmlString(builder);
        }
Пример #4
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 numberbox 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString NumberBox(this HtmlHelper htmlHelper, string exp, NumberBoxSettings settings = null)
        {
            settings = settings ?? new NumberBoxSettings();

            var builder = new EasyUITagBuilder("input", "easyui-numberbox", settings);

            builder.MergeAttribute("name", exp);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-input");
            builder.GenerateId("txt" + exp);
            return(new ExtendHtmlString(builder));
        }
Пример #5
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 combotree 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 cbo 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString ComboTree(this HtmlHelper htmlHelper, string exp, ComboTreeSettings settings = null)
        {
            settings = settings ?? new ComboTreeSettings();

            var builder = new EasyUITagBuilder("select", "easyui-combotree", settings);

            builder.MergeAttribute("name", exp);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-input");
            builder.GenerateId("cbo" + exp);
            return(new ExtendHtmlString(builder));
        }
Пример #6
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 textbox 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString TextMultiBox(this HtmlHelper htmlHelper, string exp, TextBoxSettings settings = null)
        {
            settings           = settings ?? new TextBoxSettings();
            settings.Multiline = true;
            var builder = new EasyUITagBuilder("textarea", "easyui-textbox", settings);

            builder.MergeAttribute("name", exp);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-multi");
            builder.GenerateId("txt" + exp);
            return(new ExtendHtmlString(builder));
        }
Пример #7
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 datetimespinner 元素。
        /// </summary>
        /// <typeparam name="TModel">数据模型类型。</typeparam>
        /// <typeparam name="TProperty">绑定的属性的类型。</typeparam>
        /// <param name="htmlHelper"></param>
        /// <param name="expression">指定绑定属性的表达式。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString DateTimeSpinner<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, DateTimeSpinnerSettings settings = null)
        {
            settings = settings ?? new DateTimeSpinnerSettings();

            var metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var propertyName = metadata.PropertyName;
            settings.Bind(typeof(TModel), propertyName);

            var builder = new EasyUITagBuilder("input", "easyui-timespinner", settings);
            builder.MergeAttribute("name", propertyName);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-input");
            builder.GenerateId("txt" + propertyName);
            return new ExtendHtmlString(builder);
        }
Пример #8
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 textbox 元素。
        /// </summary>
        /// <typeparam name="TModel">数据模型类型。</typeparam>
        /// <typeparam name="TProperty">绑定的属性的类型。</typeparam>
        /// <param name="htmlHelper"></param>
        /// <param name="expression">指定绑定属性的表达式。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString TextMultiBox <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, TextBoxSettings settings = null)
        {
            settings           = settings ?? new TextBoxSettings();
            settings.Multiline = true;

            var metadata     = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var propertyName = metadata.PropertyName;

            settings.Bind(typeof(TModel), propertyName);

            var builder = new EasyUITagBuilder("textarea", "easyui-textbox", settings);

            builder.MergeAttribute("name", propertyName);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-multi");
            builder.GenerateId("txt" + propertyName);
            return(new ExtendHtmlString(builder));
        }
Пример #9
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 validatebox 元素。使用一个枚举类型输出 Key-Value 数组,Value 是使用 <see cref="EnumDescriptionAttribute"/> 标注的。
        /// </summary>
        /// <typeparam name="TModel">数据模型类型。</typeparam>
        /// <typeparam name="TProperty">绑定的属性的类型。</typeparam>
        /// <param name="htmlHelper"></param>
        /// <param name="expression">指定绑定属性的表达式。</param>
        /// <param name="enumType">要绑定的枚举类型。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static ExtendHtmlString ComboBox <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, Type enumType, ComboBoxSettings settings = null)
        {
            settings = settings ?? new ComboBoxSettings();

            var metadata     = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
            var propertyName = metadata.PropertyName;

            settings.Bind(typeof(TModel), propertyName);

            var builder = new EasyUITagBuilder("select", "easyui-combobox", settings);

            builder.MergeAttribute("name", propertyName);
            builder.MergeAttribute("data-options", SettingsSerializer.Serialize(settings));
            builder.AddCssClass("form-input");
            builder.InnerHtml = BuildEnumOptions(enumType);
            builder.GenerateId("cbo" + propertyName);
            return(new ExtendHtmlString(builder));
        }