0
nabass created
hi sir, i want to create new feature and i tried to use ( SelectionStringValueType ) to make it dropdown but it doesn't work i followed the step within this documentation https://docs.abp.io/en/abp/8.1/Features i faced a problem in console here is my code:
- ABP Framework version: v8
- UI Type:MVC
- Database System: EF Core (SQL Server)
2 Answer(s)
-
0
Hi,
You can try:
public class MyFeatureDefinitionProvider : FeatureDefinitionProvider { public override void Define(IFeatureDefinitionContext context) { var op = new List<string>(){"GROUP", "WAREHOUSE"}; var validate = new DropDownValueValidator(op); var myGroup = context.AddGroup("MyApp"); myGroup.AddFeature( "Options", defaultValue: "GROUP", displayName: new FixedLocalizableString("Options"), description: new FixedLocalizableString("Options"), valueType: new SelectionStringValueType(validate) { ItemSource = new StaticSelectionStringValueItemSource( new LocalizableSelectionStringValueItem() { Value = "GROUP", DisplayText = new LocalizableStringInfo("Test", "GROUP") },new LocalizableSelectionStringValueItem() { Value = "WAREHOUSE", DisplayText = new LocalizableStringInfo("Test", "WAREHOUSE") }), } ); } } public class DropDownValueValidator : IValueValidator { private readonly List<string> _validOptions; public DropDownValueValidator(List<string> validOptions) { Name = validOptions[0]; _validOptions = validOptions; } public bool IsValid(object? value) { if(value == null) { return false; } return _validOptions.Contains(value.ToString()); } public string Name { get; } public object? this[string key] { get => key; set { key = (string)value; } } public IDictionary<string, object?> Properties { get; } }
-
0