组合框extjs的设定值

Eag*_*Fox 1 combobox setvalue extjs4.1

这是我的组合模型

Ext.define('ExtJS.myApp.ComboModel', {
    extend: 'Ext.data.Model',
    alias: 'widget.combomodel',
    fields: [
        { name: 'ID', type: 'int' },
        { name: 'title', type: 'string' }
     ]
});
Run Code Online (Sandbox Code Playgroud)

这是comboStore

   this.comboStore = Ext.create('Ext.data.Store', {
        model: 'ExtJS.myApp.ComboModel',
        autoLoad: true,
        scope: this,
        proxy: {
            type: 'ajax',
            scope: this,
            url: 'myApp/GetRecords',
            reader: {
                type: 'json',
                root: 'data'
            }
        }
    });

    this.myComboBox = Ext.create('Ext.form.ComboBox', {
        store: this.comboStore,
        queryMode: 'local',
        displayField: 'title',
        valueField: 'ID'
    });
Run Code Online (Sandbox Code Playgroud)

这是我为我的商店获得的json对象:

{"ID":"111","title":"Ext Page 1"}
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试像这样设置组合框的值.this.myComboBox.setValue( '111');

组合框显示"111"而不是"Ext Page 1"

在设置valueField时,我需要做什么才能使组合框显示displayField.例如.我想将值设置为"Ext Page 1"供用户查看,但在保存值时,我实际上想要保存"111"

Ami*_*ine 5

尝试:

this.myComboBox.setValue(111);
Run Code Online (Sandbox Code Playgroud)

代替:

this.myComboBox.setValue('111');
Run Code Online (Sandbox Code Playgroud)