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

[Solved] DropDownList for enum field?

0 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jerret
Top achievements
Rank 1
Jerret asked on 26 Apr 2011, 06:10 PM
I have a simple model where I wish to have a enum represented as a drop down in the grid.

Model:
public class VariableDataFieldDefinition
{
    public enum DataType
    {
        [Description("Amount")]
        Decimal,
        [Description("String")]
        String,
        [Description("Date with Time")]
        DateTime,
        [Description("Number")]
        Integer
    }
 
    public int Id { get; set; }
 
    [Required]
    [Display(Name = "Field Name")]
    public string FieldName { get; set; }
 
    [Required]
    [Display(Name = "Field Type")]
    public DataType FieldType { get; set; }
}

The grid:
@(Html.Telerik().Grid<VariableDataFieldDefinition>()
        .Name("Grid")
        .DataKeys(keys =>
        {
            keys.Add(p => p.Id);
        })
        .ToolBar(commands => {
            commands.Insert();
        })                   
        .DataBinding(dataBinding =>
            dataBinding.Ajax()
                .Delete("_DeleteBatchEditing", "Grid")
        )
        .Columns(columns =>
        {
            columns.Bound(p => p.FieldName).Width(210);
            columns.Bound(p => p.FieldType).Width(130);
            columns.Command(commands => commands.Delete()).Width(180).Title("Delete");           
        })
        .Editable(editing => editing.Mode(GridEditMode.InCell))
        .Scrollable()
    )

However, when the grid is rendered I never get a drop down for the enum type. Any suggestions?

Thanks,
Jerret

Tags
Grid
Asked by
Jerret
Top achievements
Rank 1
Share this question
or