6.8.0, Angular, .NET Framework
I think it would be good to have a simple way to define sorting on the public pricing table page.
Right now sorting is done in alphabetic order based on feature names. But this might not always make sense (which is why I have to use a prefix ... and that's not so beautiful ...)
I suggest something like an additional property for FeatureMetadata
, e.g.: public int SortIndex { get; set; }
Prioritize this property for sorting if set and sort the rest in alphabetic order if not set (or value is 0). And if some values are the same, also use alphabetic order.
What do you think about it?
3 Answer(s)
-
0
I just found a question by @vladsd asking for something similar: [Extending feature properties #4618](https://support.aspnetzero.com/QA/Questions/4618)
-
0
@alexanderpilhar did that work for you ?
-
0
@ismcagdas yes, that gave me the right hints on what to do!
In case somebody else wants to implement sorting or ASPNETZERO team decides to implement it:
- Add the following property to
FeatureMetadata.cs
andFlatFeatureSelectDto.cs
:public int? SortIndex { get; set; }
- Edit
CustomDtoMapper.cs
:- Add class (see: Before and After Map Action):
public class MapFeatureSortIndexAction : IMappingAction<Feature, FlatFeatureSelectDto> { public void Process(Feature source, FlatFeatureSelectDto destination) { destination.SortIndex = (source[FeatureMetadata.CustomFeatureKey] as FeatureMetadata)?.SortIndex; } }
- Change
configuration.CreateMap<FlatFeatureSelectDto, Feature>().ReverseMap();
toconfiguration.CreateMap<FlatFeatureSelectDto, Feature>().ReverseMap().AfterMap<MapFeatureSortIndexAction>();
- Edit
TenantRegistrationAppService.cs
:
public async Task<EditionsSelectOutput> GetEditionsForSelect() { ... var flatFeatures = ObjectMapper .Map<List<FlatFeatureSelectDto>>(features) .OrderByDescending(f => f.SortIndex.HasValue) .ThenBy(f => f.SortIndex) .ThenBy(f => f.DisplayName) .ToList(); ... }
Cheers!
- Add the following property to