Enum in GridView

4 posts, 0 answers
  1. Umut
    Umut avatar
    6 posts
    Member since:
    Mar 2015

    Posted 25 Mar 2015 Link to this post

    Hi, 
    I have a model like below:

    public class SysUnit : BaseModel
        {
            public string Name { get; set; }
            public string Prefix { get; set; }
     
            public SysUnitGroup SysUnitGroup { get; set; }
     
        }
    public enum SysUnitGroup
        {
            Money,
            Length,
            Weigh,
        }


    When i used scaffold template of Telerik, it is not generating dropdown for Enum at insert and edit actions. 

    I searched and try lots of things to bind enum in Grid Editview.. Is there any tutorial ? 



  2. Tim Weckx
    Tim Weckx avatar
    4 posts
    Member since:
    Jul 2012

    Posted 25 Mar 2015 Link to this post

    See if the example from this post will help: Enum in grid's dropdown list column (edit popup mode)
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Umut
    Umut avatar
    6 posts
    Member since:
    Mar 2015

    Posted 26 Mar 2015 Link to this post

    Yes i saw this example but i cant work the client template. 
    Is there a generic way to do this ?
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 27 Mar 2015 Link to this post

    Hi Umut,

    Can you please provide more details about your difficulties with the client template and share some code that we can examine? 
    Regarding your second question - you can use a dynamic type model to achieve a more generic approach. For example: 
    @model dynamic
    @using EnumerationEditing.Models
     
    @(Html.Kendo().DropDownListFor(m => m)
            .DataTextField("Text")
            .DataValueField("Value")
            .BindTo(Extensions.EnumToSelectList(((Object)Model).GetType()))
    )


    Regards,
    Alexander Popov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready