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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem setting Enum text values in Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

144213 Apr 24,2019 01:57 PM UTC Apr 25,2019 02:34 PM UTC ASP.NET MVC 2
loading
Tags: Grid
Erik
Asked On April 24, 2019 01:57 PM UTC

Hello,

I'm trying to show Enum text values in a grid control following the tutorial provided in this site:


But even the grid shows the numeric values. Here's is my code for reference:

View
@using Syncfusion.JavaScript.Shared.Serializer
@using ######################

@{
    DataManagerConverter.Serializer = new DMSerial();
}

@(Html.EJ().Grid<object>("FlatGrid")
                       .Datasource((IEnumerable<object>)ViewBag.datasource)
                       .AllowPaging()    /*Paging Enabled*/
                       .AllowFiltering()
                       .Columns(col =>
                        {
                            col.Field("OrderID").HeaderText("OrderID").IsPrimaryKey(true).Width(75).Add();
                            col.Field("FirstName").HeaderText("FirstName").Width(75).Add();
                            col.Field("LastName").HeaderText("LastName").Width(75).Add();
                            col.Field("Title").HeaderText("Title").Width(110).Add();
                            col.Field("Unit").HeaderText("Unit").Width(75).Add();
                        }))

Controller
using System.Web.Mvc;
using System.Runtime.Serialization;
using Syncfusion.JavaScript.Shared.Serializer;
using System.Collections.Generic;
using System.Web.Script.Serialization;

namespace ################
{
    public class DMSerial : IDataSourceSerializer
    {
        public string Serialize(object obj)
        {
            return Serialize(obj, null);
        }
        public string Serialize(object obj, object settings = null)
        {
            var str = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
            return str;
        }
    }

        public class HomeController : BaseController
    {
        public static List<Details> obj = new List<Details>();
        public ActionResult Index()
        {
            var DataSource = GetInversedData();
            ViewBag.datasource = DataSource;
            return View();
        }

        public static List<Details> GetInversedData()
        {
            List<Details> obj = new List<Details>();
            for (var i = 0; i < 1; i++)
            {
                obj.Add(new Details() { OrderID = 10001, FirstName = "Nancy", LastName = "Davolio", Title = "Sales Representative", Unit = UnitOfMeasure.g });
                obj.Add(new Details() { OrderID = 10002, FirstName = "Andrew", LastName = "Fuller", Title = "Vice President, Sales", Unit = UnitOfMeasure.Kg });
                obj.Add(new Details() { OrderID = 10003, FirstName = "Janet", LastName = "Leverling", Title = "Sales Representative", Unit = UnitOfMeasure.l });
                obj.Add(new Details() { OrderID = 10004, FirstName = "Margaret", LastName = "Peacock", Title = "Sales Representative", Unit = UnitOfMeasure.Nr });
                obj.Add(new Details() { OrderID = 10005, FirstName = "Steven", LastName = "Buchanan", Title = "Sales Manager", Unit = UnitOfMeasure.Nr });
                obj.Add(new Details() { OrderID = 10006, FirstName = "Michael", LastName = "Suyama", Title = "Sales Representative", Unit = UnitOfMeasure.g });
                obj.Add(new Details() { OrderID = 10007, FirstName = "Robert", LastName = "King", Title = "Sales Representative", Unit = UnitOfMeasure.Kg });
                obj.Add(new Details() { OrderID = 10008, FirstName = "Laura", LastName = "Callahan", Title = "Inside Sales Coordinator", Unit = UnitOfMeasure.l });
            }
            return obj;
        }

        public class Details
        {
            public int OrderID { get; set; }
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string Title { get; set; }
            [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
            public UnitOfMeasure Unit { get; set; }
        }


        public enum UnitOfMeasure
        {
            [EnumMember(Value = "Number")]
            Nr = 0,
            [EnumMember(Value = "Kilogram")]
            Kg = 1,
            [EnumMember(Value = "Gram")]
            g = 2,
            [EnumMember(Value = "Liter")]
            l = 3
        }

    }
}


Att,

Erik
Replied On April 24, 2019 02:00 PM UTC

Hi,

Please, move this thread to ASP.NET MVC - EJ1 as this problem happens with the EJ1.


Thanks!

Vignesh Natarajan [Syncfusion]
Replied On April 25, 2019 02:34 PM UTC

Hi Luis,  
 
Thanks for contacting Syncfusion forums 
 
Query: “I'm trying to show Enum text values in a grid control following the tutorial provided in this site: 
 
We have validated the defect you have initiated with us. Thank you for the taking the time to report the issue and helping us improve our product. At Syncfusion we are committed to fixing all the validated defect (subject to technological feasibility and Product Development Life Cycle) and including the fix for the defect in our subsequent 2019 Volume 2 release. You can track the current status of your request, review the resolution timeline and contact us for any further inquiries through this link.  

 
 
Note: To view the above feedback, kindly login into your account.
  
Till then we appreciate your patience.    
 
 
Regards, 
Vignesh Natarajan 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

Live Chat Icon For mobile
Live Chat Icon