3

我需要将 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'
    }],
});
4

1 回答 1

0

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

valueField: 'id'
于 2012-10-18T08:06:24.527 回答