Cannot display enum values on kendo MVC grid?

2 posts, 0 answers
  1. wawar
    wawar avatar
    2 posts
    Member since:
    Nov 2016

    Posted 06 Dec 2016 Link to this post

    Enum class

    public class Voltage
      {
          public int Id{ get; set; }
          public string RefNo { get; set; }
          public VoltageLevel VoltageLevel { get; set; }
      }
      public enum VoltageLevel
      {
          LV = 1,
          MV = 2,
          HV = 3  
    }

     

    Controller

    public ActionResult Voltage_Read([DataSourceRequest]DataSourceRequest request)
         {
             IQueryable<Voltage> voltage= db.Voltage;
             DataSourceResult result = voltage.ToDataSourceResult(request, voltage=> new {
                 Id = voltage.Id,
                 RefNo = voltage.RefNo,
                 VoltageLevel = voltage.VoltageLevel,
             });
             return Json(result);
         }

     

    View

    @(Html.Kendo().Grid<entities.voltage>()
    .Name("grid")
    .Columns(columns =>
    {
    columns.Bound(c => c.RefNo);
    columns.Bound(c => c.VoltageLevel); //here the voltagelevel didnt show.
    })

     

     

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5910 posts

    Posted 08 Dec 2016 Link to this post

    Hello,

    The following code library entry provides an example of this: http://www.telerik.com/support/code-library/ajax-editing-with-enumerations. For your convenience I am attaching here another sample modified to use the classes from your post.

    Regards,

    Marin Bratanov
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Back to Top