Ejemplo n.º 1
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 HtmlHelper ComboTree(this HtmlHelper htmlHelper, string exp, ComboTreeSettings settings = null)
        {
            var options = SettingsSerializer.Serialize(settings);

            htmlHelper.ResetBuilderWithCheck("INPUT", "cbo", exp);
            htmlHelper.Builder.TagClosed = true;
            htmlHelper.AddStyle("width", "160px")
            .EasyUI("easyui-combotree", options);

            return(htmlHelper);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 combotree 元素。
        /// </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 HtmlHelper <TModel> ComboTree <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, ComboTreeSettings settings = null)
        {
            var metadata     = new ModelPropertyBinder(expression);
            var propertyName = metadata.PropertyName;

            settings = settings ?? new ComboTreeSettings();
            settings.Bind(typeof(TModel), propertyName);
            var options = SettingsSerializer.Serialize(settings);

            htmlHelper.ResetBuilder("INPUT", "cbo" + propertyName, propertyName);
            htmlHelper.AddStyle("width", "160px")
            .EasyUI("easyui-combotree", options);

            return(htmlHelper);
        }