This is a migrated thread and some comments may be shown as answers.

Cannot display enum values on kendo MVC grid?

1 Answer 623 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wawar
Top achievements
Rank 1
wawar asked on 06 Dec 2016, 09:05 AM

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.
})

 

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 08 Dec 2016, 08:16 AM

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.
Tags
Grid
Asked by
wawar
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or