[Flags]Enum and [Display(Description = "some text")]

I have a situation where I want to use an Enum decorated with the [Flags] attribute so I can do bitwise comparisons against multiple project sectors, which are stored in the database as an integer value.

The sectors often include spaces in the description, so I have to decorate the Enum value with [Display(Description = "some text")], like this:


    [Flags]
    public enum Sector
    {
		[Display(Description = "")]
		Unspecified = 0,
		[Display(Description = "Arts + Culture")]
		ArtsCulture = 1,
		[Display(Description = "Commercial + Office")]
		CommercialOffice = 2,
		Education = 4,
		[Display(Description = "Emergency Services")]
		EmergencyServices = 8,
		[Display(Description = "Health Care")]
		HealthCare = 16,
		Hospitality = 32,
        Industrial = 64,
		[Display(Description = "Institutional + Religious")]
		InstitutionalReligious = 128,
		[Display(Description = "Mixed Use")]
		MixedUse = 256,
		[Display(Description = "Parking Structure")]
		ParkingStructure = 512,
		[Display(Description = "Public Works + Operations")]
		PublicWorksOperations = 1024,
		[Display(Description = "Residential High Rise")]
		ResidentialHighRise = 2048,
		[Display(Description = "Residential Low Rise")]
		ResidentialLowRise = 4096,
		[Display(Description = "Retail")]
		Retail = 8192,
		[Display(Description = "Seniors + Continuing Care")]
		SeniorsContinuingCare = 16384,
		[Display(Description = "Sports + Recreation")]
		SportsRecreation = 32768
	}

The Radzen DataGrid does a great job of using the description instead of the Enum name, except when there are multiple sectors that match a bitwise comparison.

Here is some example output.

Note how the unhighlighted rows use the Display(Description) values (for a single item), but the highlighted row uses the Enum names (when multiple items matched the bitwise value).

Is there a way to fix this?

You can define Template for this column to display desired content.

Could you provide an example of how to do this? Thank you!

There are plenty of examples on how to set DataGrid column template in our demos. You can also check the EnumExtension class: