I have a grid that is sourced by a List of Objects within my model (local binding). I need to have the editor for the Name column (the only column in the grid) to be a ComboxBox where they can choose from a specified list. I got that part working, however, whenever I leave the combobox, it sets the column to the default value for the name field instead of the chosen item from the combobox. I can not figure out what I am doing wrong.
Here is my grid:
@(Html.Kendo().Grid(Model.Locations) .Name("LocationsGrid") .ToolBar(toolbar => { toolbar.Create().Text("Add Location"); }) .HtmlAttributes(new { style = "height: 150px;" }) .Columns(columns => { columns.Bound(l => l.Name); columns.Command(cmd => cmd.Destroy().Text("<i class='fa fa-trash-o'></i>")).Width(50); }) .Scrollable() .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false)) .DataSource(ds => ds.Ajax() .Batch(true) .ServerOperation(false) .Model(model => { model.Id(p => p.Id); model.Field(l => l.Name).DefaultValue("Select a Location"); }) .Create(create => create.Action("AddLocationToProcess", "ProjectConfiguration")) .Destroy(destroy => destroy.Action("RemoveLocationFromProcess", "ProjectConfiguration")) ) .Events(events => events.Edit("LocationsGrid_edit")) )
Here is my Editor:
@model int?@(Html.Kendo().ComboBoxFor(model => model) .Name("SweepTriggeredLocationCB_" + new Random().Next()) .DataTextField("Name") .DataValueField("Id") .Placeholder("Select Location...") .Suggest(true) .Filter(FilterType.StartsWith) .DataSource(ds => { ds.Read(read => read.Action("GetAddProcessLocations", "ProjectConfiguration").Data("GetAddLocationData")); }) .Value(Model.HasValue ? Model.Value.ToString() : null) .Events(events => events.Change("StandardComboBox_change")))
Here is the portion of my Model showing the UIHint for the Editor:
[Required(ErrorMessage = "{0} is required.")][NoWhiteSpace(ErrorMessage = "{0} cannot begin or end with a space.")][UIHint("SweepTriggeredLocationEditor")]public string Name { get; set; }