how to make a dynamic combobox

  • hi I am trying to load the items of a combobox from a remote file.
    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


  • Maybe you can compare it with my live-demo:
    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)


  • yes in firebug i see the file was successfuly requested


  • Did you verify via firebug that the request is being made and coming back? Add an handler for the store's loadexception to see if you get an error processing the response.