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

dropdown list either saving data or cascading

1 Answer 231 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 29 Nov 2018, 06:36 PM

I have a problem where if I add the "for" tag to my dropdown list my cascading stops working.

Here is the code that allows for selecting an item in the dropdown list which changes what is seen in the second dropdown list:

<kendo-dropdownlist name="Countries" class="jProfileMod" datatextfield="CountryName" datavaluefield="Id" bind-to="Model.Countries" index="1"></kendo-dropdownlist>
 
 
<kendo-dropdownlist name="DocumentTypes" for="GovIdTypeID" class="jProfileMod" datatextfield="Name" datavaluefield="Id"  bind-to="Model.GovIdTypes" cascade-from="Countries" cascade-from-field="IssuingCountry.Id"></kendo-dropdownlist>

And here I have added some code so that my model gets updated when the HTML post is called:

<kendo-dropdownlist name="Countries" for="CountryID" class="jProfileMod" datatextfield="CountryName" datavaluefield="Id" bind-to="Model.Countries" index="1"></kendo-dropdownlist>
 
<kendo-dropdownlist name="DocumentTypes" for="GovIdTypeID" class="jProfileMod" datatextfield="Name" datavaluefield="Id"  bind-to="Model.GovIdTypes" cascade-from="Countries" cascade-from-field="IssuingCountry.Id"></kendo-dropdownlist>

as soon as I do that, the fist dropdown box no longer affects the second one.

the only thing I add is: for="CountryId" in the first dropdown.

The model:

public Guid CountryID { get; set; }
public Guid GovIdTypeID { get; set; }
public List<Country> Countries { set; get; }
public List<DocumentType> GovIdTypes { set; get; }

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 04 Dec 2018, 01:19 PM
Hello Andrew,

In general, the DropDownList cascading functionality uses the value specified in the cascade-from attribute to match the parent widget by id. However, when using the for attribute, this automatically sets the DropDownList's name and id attributes to be equal to the specified value. Thus, the actual rendered HTML is the following:
<input type="text" name="CountryID" id="CountryID" ..... />

However, since the value of the cascade-from attribute differs, this causes the cascading functionality to not correctly identify the parent widget. Taking this into consideration, you should be able to resolve the issue by modifying the cascade-from attribute accordingly:
<kendo-dropdownlist  for="GovIdTypeID"
  class="jProfileMod"
  datatextfield="Name"
  datavaluefield="Id" 
  bind-to="Model.GovIdTypes"
  cascade-from="CountryID"
  cascade-from-field="IssuingCountry.Id">
</kendo-dropdownlist>

Regards,
Dimitar
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
Andrew
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or