public override void CreateEditor() { if (UseEditor()) { var editorType = EditorTypeRegistry.Get(EditorType); editor = Widget.CreateOfType(editorType, e => e.AppendTo(Container), GetEditorOptions()); return; } base.CreateEditor(); }
private Widget CreateField(jQueryObject container, PropertyItem item) { var fieldDiv = J("<div/>") .AddClass("field") .AddClass(item.Name) .Data("PropertyItem", item) .AppendTo(container); if (!String.IsNullOrEmpty(item.CssClass)) { fieldDiv.AddClass(item.CssClass); } string editorId = options.IdPrefix + item.Name; string title = DetermineText(item.Title, prefix => prefix + item.Name); string hint = DetermineText(item.Hint, prefix => prefix + item.Name + "_Hint"); string placeHolder = DetermineText(item.Placeholder, prefix => prefix + item.Name + "_Placeholder"); var label = J("<label/>") .AddClass("caption") .Attribute("for", editorId) .Attribute("title", hint ?? title ?? "") .Html(title ?? "") .AppendTo(fieldDiv); if (item.Required == true) { J("<sup>*</sup>") .Attribute("title", Q.Text("Controls.PropertyGrid.RequiredHint")) .PrependTo(label); } var editorType = EditorTypeRegistry.Get(item.EditorType ?? "String"); var elementAttr = editorType.GetCustomAttributes(typeof(ElementAttribute), true); string elementHtml = (elementAttr.Length > 0) ? elementAttr[0].As <ElementAttribute>().Value : "<input/>"; var element = Widget.ElementFor(editorType) .AddClass("editor") .AddClass("flexify") .Attribute("id", editorId) .AppendTo(fieldDiv); if (element.Is(":input")) { element.Attribute("name", item.Name ?? ""); } if (!placeHolder.IsEmptyOrNull()) { element.Attribute("placeholder", placeHolder); } object editorParams = item.EditorParams; Type optionsType = null; var optionsAttr = editorType.GetCustomAttributes(typeof(OptionsTypeAttribute), true); if (optionsAttr != null && optionsAttr.Length > 0) { optionsType = optionsAttr[0].As <OptionsTypeAttribute>().OptionsType; } Widget editor; if (optionsType != null) { editorParams = jQuery.ExtendObject(Activator.CreateInstance(optionsType), item.EditorParams); editor = (Widget)(Activator.CreateInstance(editorType, element, editorParams)); } else { editorParams = jQuery.ExtendObject(new object(), item.EditorParams); editor = (Widget)(Activator.CreateInstance(editorType, element, editorParams)); } editor.Initialize(); if (editor is BooleanEditor && (item.EditorParams == null || !Q.IsTrue(item.EditorParams["labelFor"]))) { label.RemoveAttr("for"); } if (Script.IsValue(item.MaxLength)) { SetMaxLength(editor, item.MaxLength.Value); } if (item.EditorParams != null) { ReflectionOptionsSetter.Set(editor, item.EditorParams); } J("<div/>") .AddClass("vx") .AppendTo(fieldDiv); J("<div/>") .AddClass("clear") .AppendTo(fieldDiv); return(editor); }
public override void InitQuickFilter(QuickFilter <Widget, object> filter) { base.InitQuickFilter(filter); filter.Type = EditorTypeRegistry.Get(EditorType); }