Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo dropdownlist disappears in kendo window

I have two kendo windows in a page(add and edit), both having the dropdownlist with same name.

@(Html.Kendo().DropDownList()
.Name("TypeId") 
    .DataTextField("TypeName") 
    .DataValueField("Id") 
    .datasource(source => 
    {
      source.Read(read =>
           {
                read.Action("Action", "Controller"); 
           })
     }))

When accessing the add window the dropdown looks good, then open and close the add window for three times and then access the edit window.

the second time I access the edit window the dropdownlist disappears, then a textbox appears in place of dropdownlist.

When I use MVC4 dropdownlist control there is no problem, the problem is only with kendo dropdownlist.

Can anyone advice what I am doing wrong.

like image 478
user1870358 Avatar asked Dec 14 '25 10:12

user1870358


1 Answers

You cannot have multiple widgets with the same name - you need to ensure that each widget has unique name.

Behind the scenes you assign name to the widget via the Name method - it assign's an ID to the html wrapping element which is used to find the widget and initialize it. As you might know if you have two html elements with the same id - jQuery will return always the first one and because of this the second widget will not be initialized and will remain as regular textbox input.

like image 193
Petur Subev Avatar answered Dec 16 '25 22:12

Petur Subev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!