We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to show enum text values in grid columns?

This Knowledge base explains how to show enum text values in the Grid column.

Solution:

By default, the JavaScriptSerializer is used to serialize the DataSource in Grid. It serializes the enums to numeric values and not their string representation. So, if you want to serialize the enum as its name instead of numeric value, it can be achieved using the custom serializer in DataManager and referring the custom serializer in the View page.

The following code example demonstrates how to show enum text values in Grid column.

1.Render the Grid control.

MVC

 

2.In the server side we have serialized the datasource using the Newtonsoft.Json serializer. The enum values are converted into string by using the Newtonsoft StringEnumConverter.

C#

 

ASP.NET CORE

 

C#

 

Angular

HTML

 

TS

 

Result:

Figure 1 Showing enum text values in grid column

 

Article ID: Published Date: Last Revised Date: Platform: Control:
9264 09/11/2018 09/11/2018 ASP.NET Core Grid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.