PDA

View Full Version : Populating ComboBox with JSON



reang
23 Apr 2007, 11:32 PM
Hi...

Anyone can help me....

please tell me how to populating ComboBox with JSON?

regards.

ryanthe
24 Apr 2007, 12:30 AM
var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'http://domain/search.php'
}),
reader: new Ext.data.JsonReader({
root: 'isi',
totalProperty: 'totalCount',
id: 't_id'
}, [
{name: 'id', type: 'int'},
{name: 'nama', type: 'string'}
]),
remoteSort: true
});
ds.setDefaultSort('nama', 'desc');
var combo = new Ext.form.ComboBox({
store: ds,
displayField:'nama',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a Name...',
selectOnFocus:true
});
combo.applyTo('objId');



and create your object id in your html

<div id='objId' name='objId'></div>

DrZog
26 Apr 2007, 5:09 AM
Shouldn't your



<div id='objId' name='objId'></div>

be


<input id='objId' name='objId' />?