je veux faire un champs de recherche avec auto-complétion pour ceci j'utilise un Json Strore et une combobox :
avec displayField: 'location' le scripte crache(Uncaught TypeError: Cannot read property 'length' of undefined) mais j'ai testé avec displayField: 'id' et ça marche très bien donc mon problème c'est comment je peux accéder à 'location' ???
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 var store = new Ext.data.JsonStore({ url: 'Monurl', root: 'features', // the root of the array you'll send down fields: ['type','id','geometry',{location:'location',name:'name'}] }); var combo = new Ext.form.ComboBox({ store: store, displayField: 'location', typeAhead: true, mode: 'remote', queryParam: '', //contents of the field sent to server. hideTrigger: true, //hide trigger so it doesn't look like a combobox. selectOnFocus:true, width: 250, renderTo: 'search' //the id of the html element to render to. //Not necessary if this is in an Ext formPanel. });
le format de JSon qui me renvoie le serveur est :
merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 {"type":"Feature","id":"ar1","geometry":null,"properties":{"location":"locat","bbox":[xx,yy,x,y]}}
Partager