Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Hi Tim,
First thing I can say with your version 1 is: You will get missing text (because in EnumSelectionFactory will use LocalizationService to get text for each value)
2nd version should cast value to int like this:
return new SelectListItem
{
Text = n,
Value = ((int)n).ToString()
};
Hope that help!
Ha Bui
Thanks you for that. Unfortunately the code won't compile so I changed to
return Enum.GetNames(property).Select(n => new SelectListItem
{
Text = n,
Value = Convert.ToInt32(n).ToString()
});
But this causes the visitor group to crash with 'input string is not in correct format'
With the first version - the localisation service should pick up from an aml file in language. But i have one with the below format
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<languages>
<language name="en" id="en">
<shell>
<cms>
<visitorgroups>
<criteria>
<search>
<key>Term:</key>
</search>
</criteria>
</visitorgroups>
</cms>
</shell>
<enums>
<criteriapack>
<searchcriterion>
<searchvaluecondition>
<match>Match</match>
<startswith>Starts with</startswith>
</searchvaluecondition>
</searchcriterion>
</criteriapack>
</enums>
</language>
</languages>
Is that wrong?
Any other thoughts would be really appreciated
Actually i don;t need this to be perfect so I have just associated it with the actual instance of the enum. Works fine but won't win prizes
public class SearchValueSelectionFactory : ISelectionFactory
{
IEnumerable<SelectListItem> ISelectionFactory.GetSelectListItems(Type property)
{
return new List<SelectListItem>
{
new SelectListItem
{
Text = "Match",
Value = ((int)SearchValueCondition.Match).ToString()
},
new SelectListItem
{
Text = "Starts With",
Value = ((int)SearchValueCondition.StartsWith).ToString()
}
};
}
}
Cheers
Hi Tim,
Why you don't keep calm and write down correct structure in your xml lang file?
Because you just follow by error message (Missing Text ...) is enough!
<?xml version="1.0" encoding="utf-8" ?>
<languages>
<language name="English" id="en">
<enums>
<episerver>
<templates>
<alloy>
<models>
<searchvaluecondition>
<match>Match</match>
<startswith>Start With</startswith>
</searchvaluecondition>
</models>
</alloy>
</templates>
</episerver>
</enums>
</language>
</languages>
Any way, if you just want to show it then ok! ;)
BR
Ha Bui
Hello everyone
I'm building a custom visitor group but the match criteria drop down doesn't populate from an enum. I'm coding as the following
but the dojowidget doesn't pick up the enum and i can't see why and I can't see how to debug further.
If a create a custom selection factory like this
Then it will populate (horray) but when I go in to edit a saved criteria then the item the user selected is lost and needs to be readded (booooo). If I could get either one working then I'd be happy but at the moment neither works fully
As anyone got any advice/tips . As always all help sis gratefully received
Many Thanks.