I have an MVC5 application in which I have an editable grid. On the grid is a byte field named "Level" which only saves a value of either 1 or 2. When the grid is in display-mode, I would like it to say "Level 1" or "Level 2". When the grid is being edited, I would like to display radio buttons for the user. I believe MVVM is necessary in order to bind the field to the viewmodel. Could you help me wire this up so it will retrieve & update properly?
ViewModel
public class MasterLotViewModel{ public int MasterLotId { get; set; } [Display(Name = @"Master Lot")] [Range(1, 2)] [DataType("MasterLotLevel")] public byte Level { get; set; } [Display(Name = @"Start Date")] [DataType(DataType.Date)] [Required] public DateTime StartDate { get; set; } [Display(Name = @"End Date")] [DataType(DataType.Date)] public DateTime? EndDate { get; set; }}Editor Template
@model byte@Html.HiddenFor(model => model)<input class="masterLotRadios" id="Level1" name="Level" type="radio" value="1"><label for="Level1">Level 1</label><input class="masterLotRadios" id="Level2" name="Level" type="radio" value="2"><label for="Level2">Level 2</label>Grid
@(Html.Kendo().Grid<MasterLotViewModel>() .Name("masterLotGrid") .Columns(columns => { columns.Bound(x => x.MasterLotId).Visible(false); columns.Bound(x => x.Level).ClientTemplate("Level #: Level #"); columns.Bound(x => x.StartDate); columns.Bound(x => x.EndDate); columns.Command(command => { command.Edit(); }).Width(100); }) .ToolBar(toolbar => toolbar.Create()) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Pageable() .Sortable() .AutoBind(true) .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) .PageSize(10) .Events(events => events.Error("errorHandler")) .Model(model => { model.Id(x => x.MasterLotId); model.Field(m => m.Level).DefaultValue(1); }) .Read(read => read.Action("GetMasterLots", "Lot").Data("formatMasterLotData")) .Create(create => create.Action("CreateMasterLot", "Lot").Data("formatNewMasterLotData")) .Update(update => update.Action("UpdateMasterLot", "Lot").Data("formatUpdateMasterLotData")) ))