3

I need to load db values to a combo box. I can't figure out, why values are not loading into combo box. By firebug, console.log values are printed out. Here is my code for combo box,

var groups = new Ext.data.JsonStore({
    fields: [{
        id: 'id'
    }, {
        name: 'name'
    }],
    root: 'rows',
    autoDestroy: true,
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
        url: GO.settings.modules.schedule.url + 'groups.php',
    }),
    reader: {
        type: 'json',
        root: 'rows'
    },
    listeners: {
        load: function (obj, records) {
            Ext.each(records, function (rec) {
                console.log(rec.get('name'));
            });
        }
    }
});

var taskGroup = new Ext.form.ComboBox({
    name: 'Group',
    hiddenName: 'group',
    triggerAction: 'all',
    editable: false,
    fieldLabel: 'Group',
    mode: 'local',
    autoLoad: true,
    displayField: 'text',
    store: groups,
    columns: [{
        dataIndex: 'name'
    }],
});
Darin Kolev
  • 3,401
  • 13
  • 31
  • 46
DarkRose
  • 125
  • 4
  • 12
  • my json output from that URL {'rows': [{ 'id': '1', 'name': 'Google', }, { 'id': '2', 'name': 'Microsoft', }, { 'id': '3', 'name': 'Yahoo', }]} – DarkRose Oct 18 '12 at 07:46

1 Answers1

0

You've set the displayField, but you also need the valueField:

valueField: 'id'
Amalea
  • 526
  • 1
  • 6
  • 17