Custom Editor with Kendo DropDownList

3 posts, 0 answers
  1. Peter
    Peter avatar
    27 posts
    Member since:
    Jul 2019

    Posted 07 Aug 2019 Link to this post

    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. Peter
    Peter avatar
    27 posts
    Member since:
    Jul 2019

    Posted 07 Aug 2019 Link to this post

    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. 

  3. Georgi
    Admin
    Georgi avatar
    685 posts

    Posted 09 Aug 2019 Link to this post

    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.
Back to Top