how to make a dynamic combobox
Posted on November 23rd, 2008 by cfz
the remote file returns a json string.
here is my code:
var myCombo = new Ext.form.ComboBox({
store: new Ext.data.JsonStore({
url: 'GetAllInstalledPojectNames',
root:'projects',
fields: [
{name:'projectId', mapping:'projectId', type:'string'},
{name: 'projectName', mapping:'projectName', type:'string'}
]
}),
id:'AllProjects',
fieldLabel: 'Projects',
autoWidth: true,
disabled: false,
name: 'items',
typeAhead: false,
editable: false,
forceSelection:true,
triggerAction: 'all',
emptyText:'Select A Project........',
selectOnFocus:true,
mode: 'remote',
displayField: 'projectName',
valueField: 'projectId'
});
my json string:
{'projects': [{ 'projectId': 'project1', 'projectName': 'Bill'},{ 'projectId': 'project2', 'projectName': 'occu' } ]}
when i view my from i can see the combobox but when i click it nothing happens. no errors either.
any idea what could i be doing wrong?
thanks
http://fun4me.demon.nl/test/test_dev.php/city/edit/id/74
In the simple-view you see a drop-down combobox with country-names
in the detailed-view you also have a drop-down combobox with country-abbreviations (which does not work).
I don't know why the abbreviation-field does not work, since it is setup exactly the same as the name-field, but the name field does work. (Maybe it is because they use the same store and the same field country-id)