예제 #1
0
        protected virtual void UpdateItems()
        {
            ClearItems();

            var enumType = EnumTypeRegistry.Get(options.EnumKey);

            foreach (var x in Enum.GetValues(enumType))
            {
                var name = Enum.ToString(enumType, x.As <Enum>());
                AddItem(((int)x).ToString(), Q.TryGetText("Enums." + options.EnumKey + "." + name) ?? name);
            }
        }
예제 #2
0
        public RadioButtonEditor(jQueryObject input, RadioButtonEditorOptions opt)
            : base(input, opt)
        {
            if (options.EnumKey.IsEmptyOrNull() &&
                options.EnumType == null &&
                options.LookupKey.IsEmptyOrNull())
            {
                return;
            }

            if (!options.LookupKey.IsEmptyOrNull())
            {
                var lookup = Q.GetLookup <object>(options.LookupKey);
                foreach (dynamic item in lookup.Items)
                {
                    object textValue = ((dynamic)item)[lookup.TextField];
                    var    text      = textValue == null ? "" : textValue.ToString();
                    object idValue   = item[lookup.IdField];
                    string id        = idValue == null ? "" : idValue.ToString();
                    AddRadio(id, text);
                }
            }
            else
            {
                var enumType = options.EnumType ?? EnumTypeRegistry.Get(options.EnumKey);

                var enumKey = options.EnumKey;
                if (enumKey == null && enumType != null)
                {
                    var enumKeyAttr = enumType.GetCustomAttributes(typeof(EnumKeyAttribute), false);
                    if (enumKeyAttr.Length > 0)
                    {
                        enumKey = enumKeyAttr[0].As <EnumKeyAttribute>().Value;
                    }
                }

                foreach (var x in Enum.GetValues(enumType))
                {
                    var name = Enum.ToString(enumType, x.As <Enum>());
                    AddRadio(((int)x).ToString(), Q.TryGetText("Enums." + enumKey + "." + name) ?? name);
                }
            }
        }
예제 #3
0
        protected virtual void UpdateItems()
        {
            ClearItems();

            var enumType = options.EnumType ?? EnumTypeRegistry.Get(options.EnumKey);

            var enumKey = options.EnumKey;

            if (enumKey == null && enumType != null)
            {
                var enumKeyAttr = enumType.GetCustomAttributes(typeof(EnumKeyAttribute), false);
                if (enumKeyAttr.Length > 0)
                {
                    enumKey = enumKeyAttr[0].As <EnumKeyAttribute>().Value;
                }
            }

            foreach (var x in Enum.GetValues(enumType))
            {
                var name = Enum.ToString(enumType, x.As <Enum>());
                AddItem(((int)x).ToString(), Q.TryGetText("Enums." + enumKey + "." + name) ?? name);
            }
        }
예제 #4
0
 public string Format(SlickFormatterContext ctx)
 {
     return(Format(EnumTypeRegistry.Get(EnumKey), ctx.Value));
 }