将DB值加载到组合框 - EXTJS中

时间:2012-10-18 07:36:37

标签: extjs combobox jsonstore

我需要将db值加载到组合框中。我无法弄清楚,为什么值没有加载到组合框中。通过firebug,打印出console.log值。这是我的组合框代码,

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'
    }],
});

1 个答案:

答案 0 :(得分:0)

您已设置displayField,但您还需要valueField:

valueField: 'id'