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

DropDownListFor in popup edit from grid displays as textbox

1 Answer 195 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 07 Nov 2018, 11:10 AM

I have the following dropdownlistfor:

                            @(Html.Kendo().DropDownListFor(x => x.SelectedInvoicingCompanyId)
                                  .HtmlAttributes(new { @class = "form-control" })
                                  .BindTo(ViewData["allInvoicingCompanies"] as IEnumerable)
                                  .DataTextField("Name")
                                  .DataValueField("Id")
                                  .OptionLabel(new { Name = "Select company", Id = 0 }))

 

This works fine in another view with the exact same source. However i have this grid with popup edit and a custom popup edit template with this dropdownlist. In this popup edit template the dropdownlist displays as a textbox and the SelectedInvoicingCompanyId number i.e. "1".

When i press the edit button i also get the following error from jQuery:

Uncaught SyntaxError: Invalid or unexpected token
    at m (jquery-3.3.1.min.js:2)
    at Re (jquery-3.3.1.min.js:2)
    at w.fn.init.append (jquery-3.3.1.min.js:2)
    at I.fn.init.w.fn.(anonymous function) [as appendTo] (https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js:2:50106)
    at init._createPopupEditor (kendo.all.js:58951)
    at init.editRow (kendo.all.js:58796)
    at HTMLAnchorElement.<anonymous> (kendo.all.js:58532)
    at HTMLDivElement.dispatch (jquery-3.3.1.min.js:2)
    at HTMLDivElement.y.handle (jquery-3.3.1.min.js:2)

 

I can not get my head around this. I had it working some time ago, and i think it started acting this way after i updated to 2018.3.1017.

I have other dropdownlistfor in this popup edit template which are working as they should. So it's only this specific dropdownlist that doesn't load as it should.

This is one example of a working dropdownlist in the same view:

            @(Html.Kendo().DropDownListFor(x => x.SelectedPMId)
                  .HtmlAttributes(new { @class = "form-control" })
                  .BindTo(ViewData["allUsers"] as IEnumerable)
                  .DataTextField("DisplayName")
                  .DataValueField("Id")
                  .OptionLabel("Select User")
                  .Filter("contains"))

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 12 Nov 2018, 06:48 AM
Hi Sebastian,

Attached you will find a small sample based on the snippets sent. While testing this scenario at my end, the Grid behaves as expected and the SelectedInvoicingCompanyId DropDownList is properly initialized in the edit pop-up. May I ask you to modify the attached, so it reproduces the problem observed at your end and send it back to us? This way we will be able to troubleshoot the problem locally and to provide you with the most appropriate assistance on this case.

Regards,
Veselin Tsvetanov
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
DropDownList
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or