November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Try
public class IsUserCategoryCriterionSettings : CriterionModelBase
{
[DojoWidget(SelectionFactoryType = typeof(EnumCategorySelectionFactory))]
[Required]
public MyEnum Category { get; set; }
//or
[DojoWidget(SelectionFactoryType = typeof(EnumSelectionFactory))]
[Required]
public MyEnum Category { get; set; }
public override ICriterionModel Copy()
{
return ShallowCopy();
}
}
Hi,
I wonder whether this might be down to the type of SelectionFactory you're using. For visitor group criteria your selection factory needs to be an implementation of EPiServer.Personalization.VisitorGroups.ISelectionFactory whereas for properties on content types, you need an instance of EPiServer.Shell.ObjectEditing.ISelectionFactory. It's also worth noting that, for visitor group criteria there's already an inbuilt Enum selection factory called EPiServer.Web.Mvc.VisitorGroups.EnumSelectionFactory which can be used like this:
[DojoWidget(
SelectionFactoryType = typeof(EnumSelectionFactory),
AdditionalOptions = "{ selectOnClick: true }"),
Required]
public MyEnum Category { get; set; }
Try this-
public enum OrganizationTypeEnums
{
[Description("Internal")]
Internal,
[Description("External")]
External,
}
public class OrgTypeSelectionFactory : ISelectionFactory
{
public IEnumerable<SelectListItem> GetSelectListItems(Type propertyType)
{
return Enum.GetNames(typeof(OrganizationTypeEnums)).ToList()
.Select(c =>
{
return new SelectListItem { Text = c, Value = c };
});
}
}
public class UserTypeModel : CriterionModelBase
{
[DojoWidget(
SelectionFactoryType = typeof(OrgTypeSelectionFactory),
AdditionalOptions = "{ selectOnClick: true }"),
Required]
public string Type { get; set; }
public override ICriterionModel Copy()
{
var model = (UserTypeModel)base.MemberwiseClone();
model.Id = Identity.NewIdentity();
return model;
}
}
Hi.
I'm creating a criterion where I want to use a enum value as input. In order to create a dropdown to choose from I call my selection factory. But when I decorate my model property to use a selection factory, I get an error.
Following is my code.
Criterion:
I get follwong error: