如何从 JSON 设置一个 Ext.form.ComboBox 默认值?
How to set a Ext.form.ComboBox default value from JSON?
我知道这是一个简单的问题,但我一直在寻找解决方案。
首先,我得到了 FormPanel,它获取由 JSON 传递的数据,如下所示:
var formPanel = new Ext.FormPanel({
....
[
{name: 'country', mapping: 'country'}
]
...
然后,我使用包含国家/地区列表的外部文件中的数据填充商店
var countryStore = new Ext.data.SimpleStore({
fields: ['vcountry', 'vcountrydesc'],
data : Ext.ms.data.countries,
id:1,
});
我想做的是在一个Ext.form.ComboBox中设置一个默认值,定义为name: 'country'
,准确的说,我想做这样的事情:
var countryFld = new Ext.form.ComboBox({
store: countryStore,
.....
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Select Country',
value: 'country', **<---I WANT TO DO THIS, BUT TO DISPLAY A VALUE, NOT A STRING!**
....
}
});
我认为解决方案非常简单,但我坚持不懈。
很简单,我问的很傻...
解决方案与任何其他形式一样
dataIndex: 'country',
而不是
value:'country',
我知道这是一个简单的问题,但我一直在寻找解决方案。
首先,我得到了 FormPanel,它获取由 JSON 传递的数据,如下所示:
var formPanel = new Ext.FormPanel({
....
[
{name: 'country', mapping: 'country'}
]
...
然后,我使用包含国家/地区列表的外部文件中的数据填充商店
var countryStore = new Ext.data.SimpleStore({
fields: ['vcountry', 'vcountrydesc'],
data : Ext.ms.data.countries,
id:1,
});
我想做的是在一个Ext.form.ComboBox中设置一个默认值,定义为name: 'country'
,准确的说,我想做这样的事情:
var countryFld = new Ext.form.ComboBox({
store: countryStore,
.....
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Select Country',
value: 'country', **<---I WANT TO DO THIS, BUT TO DISPLAY A VALUE, NOT A STRING!**
....
}
});
我认为解决方案非常简单,但我坚持不懈。
很简单,我问的很傻... 解决方案与任何其他形式一样
dataIndex: 'country',
而不是
value:'country',