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

Grid column not binding on edit/ update

1 Answer 558 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Michael asked on 25 Oct 2018, 09:39 AM


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:

            .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())
            .Pageable(x => { x.AlwaysVisible(false); })
            .Editable(editable => editable.Mode(GridEditMode.InLine))         
            .HtmlAttributes(new { style = "height:600px;" })
            .DataSource(dataSource => dataSource
            .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.Id(item => item.DateLimitId);




This is the MerchantEditor

             .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);





1 Answer, 1 is accepted

Sort by
Viktor Tachev
Telerik team
answered on 29 Oct 2018, 08:23 AM
Hello Michael,

I have examined the code and noticed that the column was bound to the MerchantName field. However, the DropDownList editor is supposed to edit the Merchant field.

In order to have the editing work as expected I would suggest changing the column configuration so it is bound to Merchant. You can show the name in preview mode by using a ClientTemplate. The column configuration would look similar to the following:

columns.Bound(o => o.Merchant).ClientTemplate("#=Merchant.MerchantName#").EditorTemplateName("MerchantEditor").Title("Merchant").Width(150);

It is also recommended to specify default value for the Merchant column. It will be used when a new item is created. Check out the example below that illustrates how the Grid can be configured to use custom editor.

Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question