private static MvcHtmlString ForTreeEditor(HtmlHelper Html, FieldItem field, IEntityTree entity, Object htmlAttributes = null) { var fact = EntityFactory.CreateOperate(entity.GetType()); var set = entity.GetType().GetValue("Setting") as IEntityTreeSetting; if (set == null || set.Parent != field.Name) { return(null); } // 增加前端自定义属性方便修改魔方模板 var atts = htmlAttributes.ToAttrDictionary(); TryAddAttribute(atts, "class", "multiselect"); //var atts = htmlAttributes == null // ? new RouteValueDictionary() // : htmlAttributes as IDictionary<String, Object>; //if(!atts.ContainsKey("class")) atts.Add("class", "multiselect"); var root = entity.GetType().GetValue("Root") as IEntityTree; // 找到完整菜单树,但是排除当前节点这个分支 var list = root.FindAllChildsExcept(entity as IEntityTree); var data = new SelectList(list, set.Key, "TreeNodeText", entity[field.Name]); return(Html.DropDownList(field.Name, data, atts)); }
private static IHtmlContent ForTreeEditor(IHtmlHelper Html, FieldItem field, IEntityTree entity) { //var fact = EntityFactory.CreateOperate(entity.GetType()); var set = entity.GetType().GetValue("Setting") as IEntityTreeSetting; if (set == null || set.Parent != field.Name) { return(null); } var root = entity.GetType().GetValue("Root") as IEntityTree; // 找到完整菜单树,但是排除当前节点这个分支 var list = root.FindAllChildsExcept(entity); var data = new SelectList(list, set.Key, "TreeNodeText", entity[field.Name]); return(Html.DropDownList(field.Name, data, new { @class = "multiselect" })); }