Hey,
Do you still need to achieve that? I had that problem yesterday and I managed to fix it with the following changes in the EnumApiController in Enum Lists project.
static EnumApiController()
{
Assembly.ReflectionOnlyLoad("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
}
public IDictionary<string, string> GetAll(string assemblyName, string typeName)
{
var assembly = GetAssembly(assemblyName);
var type = assembly.GetType(typeName);
Dictionary<string, string> items = new Dictionary<string,string>();
foreach (FieldInfo fi in type.GetFields(BindingFlags.Public | BindingFlags.Static))
{
items.Add(fi.Name, GetEnumDescription(fi));
}
return items;
}
public static string GetEnumDescription(FieldInfo fi)
{
List<CustomAttributeData> attributes =
fi.GetCustomAttributesData().ToList();
if (attributes != null &&
attributes.Count > 0)
{
var attribute = attributes.Where(x => x.AttributeType.Name == "DescriptionAttribute").FirstOrDefault();
if (attribute != null)
return attribute.ConstructorArguments[0].Value.ToString();
else
return fi.Name;
}
else
return fi.Name;
}
Then you just need to change the js files to be able handle the Dictionary that's returned. For checkbox it would be something like that:
for (var i in $scope.enumItems) {
var isChecked = _.contains($scope.model.value, i);
$scope.selectedItems.push({ checked: isChecked, key: i, val: $scope.enumItems[i] });
}
possible to use Description instead?
hello - if my enum is annotated with a description attribute would it be possible for the datatype to use this for the label in the backoffice?
[Description("my description")]
thanks
Hey, Do you still need to achieve that? I had that problem yesterday and I managed to fix it with the following changes in the EnumApiController in Enum Lists project.
Then you just need to change the js files to be able handle the Dictionary that's returned. For checkbox it would be something like that:
is working on a reply...