I have the following json data (see below) from a webservice query (_urlTowns). I want to bind a Kendo UI dropdownlist control to this datasourceTowns.
{
"displayFieldName": "TNONAM",
"fieldAliases": {
"TNONAM": "TNONAM"
},
"fields": [{
"name": "TNONAM",
"type": "esriFieldTypeString",
"alias": "TNONAM",
"length": 16
}],
"features": [{
"attributes": {
"TNONAM": "ANSONIA"
}
}, {
"attributes": {
"TNONAM": "BETHANY"
}
}, {
"attributes": {
"TNONAM": "BRANFORD"
}
}, {
"attributes": {
"TNONAM": "WOODBRIDGE"
}
}]}
// Towns data source
var dataSourceTowns = new kendo.data.DataSource({
transport: {
read: {
url: _urlTowns,
dataType: "json",
type: 'GET'
}
},
schema: {
data: "features"
}});dataSourceTowns.read();
Do I need to set a model attribute? As I'm after populating the DDL with the dataTextValue from "TNONAM". Guess I'm confusing the "features" and "attributes".
Maybe your JSON is not the most convenient for a DropDownList but you can bind it to a KendoDropDownList with no change.
Define the DropDownList as:
Remember that
dataTextField
doesn't strictly have to be a field, might be path to the field.Where your HTML is:
For your dropdown configuration, part of your json need to be:
If json response strictly need to be that, then you may have to parse response data like: