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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to show enum text values in grid columns?

Platform: ASP.NET MVC |
Control: Grid |
Published Date: September 11, 2018 |
Last Revised Date: September 11, 2018

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

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon