我正在将我的应用程序从 ExtJs 3 迁移到 4 版本。我的表单面板上有几个组合框,以前我使用 hiddenName 和所有这些东西来提交 valueField 而不是 displayField。
我所有的调整工作正常(值字段正在提交),但我无法设置组合框的默认值,它们在页面加载后显示为空。以前,我只是通过在 config.xml 中指定“值”参数来做到这一点。有什么想法可以解决这个问题吗?
我的代码 - 模型和商店:
Ext.define('idNamePair', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'string'},
{name: 'name', type: 'string'}
]
});
var dirValuesStore = new Ext.data.Store({
model: 'idNamePair',
proxy: {
type: 'ajax',
url: '../filtervalues.json',
reader: {
type: 'json',
root: 'dir'
}
},
autoLoad: true
});
组合配置:
{
triggerAction: 'all',
id: 'dir_id',
fieldLabel: 'Direction',
queryMode: 'local',
editable: false,
xtype: 'combo',
store : dirValuesStore,
displayField:'name',
valueField:'id',
value: 'all',
width: 250,
forceSelection:true
}