Reputation: 11
I have 2 kendo dropdownlists in cshtml page. First has countries and based on the selection of countries cities are loading to the second dropdown. I am using ajax callback for this functionality. The ajax function is returning list of cities, but the dropdownbox is not loading with cities.
function countrydd_change()
{
//ajax call function
}
function LoadCity(Countryid) {
var result;
$.ajax({
url: '@Url.Action("LoadCities", "Controllername")',
data: { CountryId: Countryid },
type: 'GET',
async: false,
contentType: "application/json;charset=utf-8",
cache: false,
success: function (data) {
$("#citiesdd").data("kendoDropDownList").dataSource.read(data);
result = "Success";
},
error: function (x, t, m) {
result = "Failure"
}
});
return result.toUpperCase();
}
Is there anything wrong with the above code. Or can anyone send me sample code for this.
Thanks in Advance, Aradhya
Upvotes: 1
Views: 1521
Reputation: 14233
If your data format is correct then the correct method of adding data to datasource .data
and not .read
$("#citiesdd").data("kendoDropDownList").dataSource.data(data);
Upvotes: 1