Domanda

I'm binding a JS KendoUI dropdownlist to JSON (not using a model) which recently has been changed by adding a named array to the object (in efforts to format the JSON for a Kendo TreeView control). This broke a few things of course. The original JSON format looked like this (an array of objects):

[
 {
   "COLUMN_NAME": "OBJECTID",       
   "DATA_TYPE": "esriFieldTypeOID",              
   "CATEGORY": "Feature Data"
  },
  {
   "COLUMN_NAME": "Brand",       
   "DATA_TYPE": "esriFieldTypeString",              
   "CATEGORY": "Feature Data"
  },...    
]

now it looks like this (an object with a named array, with objects):

{
 "Hydrant": [
  {
   "COLUMN_NAME": "OBJECTID",       
   "DATA_TYPE": "esriFieldTypeOID",              
   "CATEGORY": "Feature Data"
  },
  {
   "COLUMN_NAME": "Brand",       
   "DATA_TYPE": "esriFieldTypeString",              
   "CATEGORY": "Feature Data"
  },...
],
"DisplayField": "Description",
"DefaultField" : "HydrantID"    
}

I assumed I could simply define the schema to "Hydrant" or set the dataText/ValueFields to "Hydrant.COLUMN_NAME" but no luck. What am I overlooking? I am binding this JSON format response to a dropdownlist using the "COLUMN_NAME" to populate it.

bonus: how could I use the "DefaultField" to set the default selection in the dropdownlist?

Thanks in advance!

È stato utile?

Soluzione

You can use the schema.data field of the DataSource configuration to identify the field from the response to use for its data:

schema: { data: 'Hydrant' }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top