Hi,
My grid has a column called Merchant which is supposed to turn into a dropdown list on edit.
For some reason, The initial selected value doesn't connect to the column- does not appear as selected. And when I save on update- The value of the merchant doesn't get the changes on server side- it stays with initial value!!!.
This is the grid:
@(Html.Kendo().Grid<DefaultLimitViewModel>
()
.Name("DefaultLimitsGrid")
.Columns(columns =>
{
columns.Bound(o => o.Id).Hidden();
columns.Bound(o => o.DateLimitId).Hidden();
columns.Bound(o => o.Merchant.MerchantName).EditorTemplateName("MerchantEditor").Title("Merchant").Width(150);
columns.Bound(o => o.Rail).EditorTemplateName("RailEditor").Title("Rail").Width(150);
columns.Bound(o => o.DefaultAmount).Format("{0:c}");
columns.Command(command => { command.Edit().CancelText(" ").UpdateText(" ").Text(" "); command.Destroy().Text(" "); }).Width(200);
})
.ToolBar(toolBar => toolBar.Create())
.Sortable()
.Pageable(x => { x.AlwaysVisible(false); })
.Scrollable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(new { style = "height:600px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(8)
.Read(read => read.Action("Get_LimitsDefaultData", "Limits"))
.Update(update => update.Action("UpdateDefaultLimit", "Limits"))
.Destroy(Delete => Delete.Action("DeleteDefaultLimit", "Limits"))
.Create(Create => Create.Action("CreateNewDefaultLimit", "Limits"))
.Model(
model =>
{
model.Id(item => item.DateLimitId);
})
)
)
This is the MerchantEditor
@(Html.Kendo().DropDownList()
.Name("Merchant")
.DataValueField("MerchantId")
.DataTextField("MerchantName")
.DataSource(d => d.Read("Merchants_Read", "Limits")))
this is the Merchans_Read function:
public IActionResult Merchants_Read()
{
using (var db = Db.Open())
{
var merchants = db.Select<Merchant>().OrderBy(x => x.Name).Select(mm => new MerchantModel { MerchantId = mm.Id, MerchantName = mm.Name }).ToList();
return Json(merchants);
}
}