In a asp.net mvc project I often need to fill in dropdown lists with countries to select from.
I usually setup a datasource and bind it to the dropdown list widget.
Sometimes I need to insert a "Any country" value at the top of the list.
This works fine, however when I try to insert the "any country" item (right after the data source definition) I get an error:
The error: "TypeError: r is undefined".
Can anyone point out what I am missing (I'm open for better/other solutions).
I usually setup a datasource and bind it to the dropdown list widget.
Sometimes I need to insert a "Any country" value at the top of the list.
var countryDs = new kendo.data.DataSource({ transport: { read: { type: "POST", url: '@Url.Action("GetCustomerCountries", "System")', data: function () { return { customerId: parseInt("@Model.CustomerId", 10) } }, dataType: "json", contentType: 'application/json; charset=utf-8' }, parameterMap: function (data, type) { return kendo.stringify(data); } }, schema: { model: { fields: { CustomerId: { type: "number" }, CountryId: { type: "number" }, CountryName: { type: "string" }, CountryAbbrev: { type: "string" } } } }});$("#grid-filter-country").kendoDropDownList({ dataTextField: "CountryName", dataValueField: "CountryId", dataSource: countryDs, value: GetCountry()});This works fine, however when I try to insert the "any country" item (right after the data source definition) I get an error:
countryDs.insert(0, { "CustomerId": 1, "CountryId": 0, "CountryName": "Any country", "CountryAbbrev": "Any" });countryDs.sync();The error: "TypeError: r is undefined".
Can anyone point out what I am missing (I'm open for better/other solutions).