private void InitEdit() { Edit = new XafBootstrapDropdownEdit(); Edit.Items.List.Clear(); if (typeof(Enum).IsAssignableFrom(MemberInfo.MemberType)) { foreach (var item in Enum.GetValues(MemberInfo.MemberType)) { int value = (int)item; string displayValue = GetXafDisplayName((Enum)item); Edit.Items.Add(new XafBootstrapDropdownItem() { Text = displayValue, Value = value }); } } Edit.PropertyName = PropertyName; }
private void InitEdit() { Edit = new XafBootstrapDropdownEdit(); Edit.Items.ItemImageHeight = 100; Edit.Items.ItemImageWidth = 100; var path = HttpContext.Current.Server.MapPath("bootstrap_themes"); if (Directory.Exists(path)) { foreach (var item in Directory.GetDirectories(path).Select(f => new DirectoryInfo(f))) { var editItem = Edit.Items.Add(); editItem.Text = item.Name; editItem.Value = item.Name; if (File.Exists(item.FullName + "\\preview.jpg")) editItem.ImageUrl = "bootstrap_themes\\" + item.Name + "\\preview.jpg"; } } }
private void InitEdit() { var memType = MemberInfo.MemberTypeInfo; if (memType.Type == typeof(SecuritySystemUser)) memType = XafTypesInfo.Instance.FindTypeInfo(SecuritySystem.UserType); CollectionOS = ObjectSpace.CreateNestedObjectSpace(); Helper = new LookupEditorHelper(Application, CollectionOS, memType, Model); var bootstrapLookup = MemberInfo.FindAttribute<BootstrapLookupAttribute>(); Boolean IsAuto = Helper.EditorMode == LookupEditorMode.Auto; if (Helper.EditorMode == LookupEditorMode.Auto) Helper.EditorMode = LookupEditorMode.AllItemsWithSearch; IsSelector = Helper.EditorMode == LookupEditorMode.AllItems; if (bootstrapLookup != null) { switch(bootstrapLookup.Kind) { case BootstapLookupKind.Auto: IsSelector = false; Helper.EditorMode = LookupEditorMode.Auto; break; case BootstapLookupKind.DropDown: IsSelector = false; Helper.EditorMode = LookupEditorMode.AllItemsWithSearch; break; case BootstapLookupKind.Selector: IsSelector = true; Helper.EditorMode = LookupEditorMode.AllItemsWithSearch; break; } } if (!IsSelector) { cs = Helper.CreateCollectionSource(Helper.ObjectSpace.GetObject(CurrentObject)); if (IsAuto || (Helper.EditorMode == LookupEditorMode.AllItemsWithSearch && bootstrapLookup == null)) IsSelector = cs != null && cs.List != null && (cs.List.Count == 0 || cs.List.Count > 20 || typeof(ITreeNode).IsAssignableFrom(MemberInfo.MemberType)); } if (cs != null && cs.List != null) foreach (var item in NewObjects) cs.List.Add(cs.ObjectSpace.GetObject(item)); String displayFormat = String.Concat(DisplayFormat); if (displayFormat == "") try { ObjectCaptionFormatAttribute aAttr = (MemberInfo.MemberTypeInfo.FindAttribute<ObjectCaptionFormatAttribute>()); if (aAttr != null) displayFormat = aAttr.FormatString; else { var lookupProperty = String.Concat(Model.GetValue<String>("LookupProperty")); if (lookupProperty != "") displayFormat = String.Format("{{0:{0}}}", lookupProperty); } } catch { } if (displayFormat == "") displayFormat = "{0}"; var App = (WebApplication.Instance as XafApplication); if (IsSelector) { DataSelector = new XafBootstrapDataSelectorEdit(this, Application, ObjectSpace, Helper); DataSelector.Caption = Model.Caption; DataSelector.PropertyName = PropertyName; DataSelector.OnClickScript = GetImmediatePostDataScript(); DataSelector.ListView = (IModelListView)App.Model.Views[App.FindLookupListViewId(memType.Type)]; DataSelector.DisplayFormat = displayFormat; DataSelector.OnCallback += DataSelector_OnCallback; DataSelector.OnOk += DataSelector_OnOk; DataSelector.OnCancel += DataSelector_OnCancel; } else { DropDown = new XafBootstrapDropdownEdit(); DropDown.OnClickScript = GetImmediatePostDataScript(); if (cs != null && cs.List != null) { var list = cs.List.OfType<object>().ToList(); var modelListView = (IModelListView)App.Model.Views[App.FindLookupListViewId(memType.Type)]; if (modelListView != null && modelListView.Sorting.Count > 0) { DropDown.SortByText = false; list = Helpers.SortListByViewSorting(modelListView, list).ToList(); } foreach (var obj in list) AddObjToDropDown(obj); } } CreateButtons(); }