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

Custom Editor with Kendo DropDownList

2 Answers 280 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 07 Aug 2019, 05:20 PM

My problem is when the editor popup shows, the drop downs are populated but are selecting the current values of the row in question.   I was referring to a few previous posts, including this example:

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/grid-popup-editing-dropdownlistfor-required/KendoUIMVC5

I thought I was missing the following:

<script>
function onEdit(e) {
@Html.Kendo().DeferredScripts(false);
}
</script>

When I look at the chrome debugger, there is only an ";" in the onEdit method, nothing is being written there.   I am using 2019.2.619.

Not sure what I am missing, thanks

Peter

2 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 07 Aug 2019, 05:40 PM

The problem was the only field that was binding to the popup editor model was the primary key, all other fields were not binding.

I had to do something like this:

    function onEdit(e) {
        setTimeout(function () {
            $("#Locations").data("kendoDropDownList").value(e.model.LOCID);
            $("#Locations").data("kendoDropDownList").trigger("change");
        }, 100);
    }

The model is the same between the grid and the popup edit but none of the "Model.{item}" are binding to the current row. 

0
Georgi
Telerik team
answered on 09 Aug 2019, 01:18 PM
Hello Peter,

A common cause for the editors to not bind to the corresponding fields of the model is when the name of the editor does not match the name of the field.

For example if you create an editor for the Age field, you have to name the editor Age as well:

// field
  public ing Age { get; set; }
 
 
// editor
 
@(Html.Kendo().NumericTextBox().Name("Age"))


Regards,
Georgi
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.
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or