I have a grid with Inline batch editing mode on. I am trying to display dropdownlist inside the grid and enable user to select values from the dropdown. The issue i am running into right now is, by default it shows null value, when clicked on that cell it shows all the dropdown values and you can select to different dropdown value. But as soon as you click outside the grid cell, it reverts the text to 'null' again. When clicked on the cell back again, it changes from 'null' to previously selected value.
ViewModel:
public class CreateAsnRequestViewModel{ [Display(Name = "UPC UOM")] public string UPCUOM { get; set; } public string UserDefinedCode { get; set; } }public class CommonDetailsCommonProperties{ public string ProductCode { get; set; } public string UserDefinedCodes { get; set; } public string UserDefinedCode { get; set; } public string CombinedValuesToSave { get; set; }}public class UOMItem : CommonDetailsCommonProperties{ public string UOM { get; set; }}public class CommonDetailsViewModel{ public List<UOMItem> UOMs { get; set; }}Controller:
CommonDetailsViewModel commonDetailsViewModel = commonService.InvokeGetCommonDetails(flag);ViewData["UOMList"] = commonDetailsViewModel.UOMs;Views:
EditorTemplate: _UOMDropDownList.cshtml
@using System.Collections@using Kendo.Mvc.UI;@(Html.Kendo().DropDownList().BindTo((IEnumerable)ViewData["UOMList"]) .DataValueField("UserDefinedCode") .DataTextField("UserDefinedCode") .Name("UPCUOM"))Main Razor View:
@(Html.Kendo().Grid<SupplierPortal.ViewModels.CreateAsnRequestViewModel>() .Name("GridViewOpenPOSelected") .Columns(columns => { columns.Bound(p => p.UPCUOM).HtmlAttributes(new { @class = "editableFiled" }).EditorTemplateName("_UPCUOMDropDownList").ClientTemplate("#:UserDefinedCode#").Width(180); }) .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false)) .AutoBind(false) .Navigatable() .DataSource(dataSource => dataSource .Ajax() .Batch(true) .PageSize(10) .Read(read => read.Action("GetSelectedPO", "Asn").Data("GetSelectedPOParameters")) .ServerOperation(false) .Model(model => { model.Id(p => p.Id); })) .Events(events => events.DataBound("gridDataBound")) .Events(events => events.DataBinding("gridDataBinding")) .Events(events => events.Edit("onEdit")))
Any help will be appreciated.
Thanks.