PDA

View Full Version : Problem using Combobox with ScriptTagProxy



KaiVolland
8 Aug 2012, 1:47 AM
Hi,

i've some problems with my ComboBox using a ScriptTagProxy.

I'd like to see the display_name of the json-objects as suggestions in the combobox and do some things on select.

The problem is, that the response is not added to the store.
Is there something wrong with the reader or something like that?

Kind regards and thx in advance


JS:

Ext.define('t3d.NominatimCombo', {
requires : [],
extend : 'Ext.form.ComboBox',
xtype : 'nominatim_combo',
loadingText: 'Bitte warten...',
emptyText: 'Ortssuche...',
minChars: 1,
queryDelay: 50,
displayField: 'display_name',
format: 'json ',
queryParam: 'q',
url: 'http://nominatim.openstreetmap.org/search?',

initComponent : function() {
var me = this;

Ext.define('NominatimModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'place_id', type: 'string'},
{name: 'display_name', type: 'string'},
],
proxy : {
type : 'scripttag',
url : this.url,
reader: {
idProperty:'place_id',
root: '',
type: 'json'
},
extraParams : {
format : this.format,
}
}
});

this.store = Ext.create('Ext.data.Store', {
model: 'NominatimModel',
callbackParam: 'json_callback'
});
me.callParent(arguments);
this.store.load();
}
});

RESPONSE:


[{"place_id":"1577073","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"315673696","boundingbox":[50.918325653076,50.938329467773,6.9007341766357,6.9207346534729],"lat":"50.9283271","lon":"6.9107343","display_name":"Berr, 236, D\u00fcrener Stra\u00dfe, Lindenthal, K\u00f6ln, Regierungsbezirk K\u00f6ln, Nordrhein-Westfalen, 50931, Deutschland","class":"shop","type":"dry_cleaning"}]

evant
8 Aug 2012, 5:29 AM
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.JsonP

This is all explained in the docs.