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

Enum in GridView

3 Answers 329 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Umut
Top achievements
Rank 1
Umut asked on 25 Mar 2015, 02:28 PM
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 ? 



3 Answers, 1 is accepted

Sort by
0
Tim Weckx
Top achievements
Rank 2
answered on 25 Mar 2015, 02:58 PM
See if the example from this post will help: Enum in grid's dropdown list column (edit popup mode)
0
Umut
Top achievements
Rank 1
answered on 26 Mar 2015, 12:53 PM
Yes i saw this example but i cant work the client template. 
Is there a generic way to do this ?
0
Alexander Popov
Telerik team
answered on 27 Mar 2015, 02:52 PM
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.

 
Tags
Grid
Asked by
Umut
Top achievements
Rank 1
Answers by
Tim Weckx
Top achievements
Rank 2
Umut
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or