我有一个组合框,其中有两种笔记本电脑,东芝和hp。加载时,选择默认值为空。我想将默认的选择值设为东芝,以便最初选择它。如在HTML中“选中”。有什么帮助吗?
laptops = Ext.create('Ext.data.Store', {
fields: ['abbr','value', 'name'],
data : [
{"abbr":"tosh","value":"toshibatypes", "name":"Toshiba"},
{"abbr":"hp","value":"hptypes", "name":"HP"}
]
});
toshibatypes = Ext.create('Ext.form.Panel', {
xtype: 'radiogroup',
defaultType: 'radio',
layout: 'hbox',
border:false,
id: 'toshiba',
width:'100%',
items: [
{
checked: true,
boxLabel: 'Toshiba 1',
name: 'toshibas',
inputValue: 'toshiba1',
xtype:'radiofield'
},
{
boxLabel: 'Toshiba 2',
name: 'toshibas',
inputValue: 'toshiba2',
xtype:'radiofield'
}
]
});
hptypes = Ext.create('Ext.form.Panel', {
xtype: 'radiogroup',
defaultType: 'radio',
layout: 'hbox',
border:false,
id: 'hp',
width:'100%',
items: [
{
checked: true,
boxLabel: 'HP 1',
name: 'hps',
inputValue: 'hp1',
xtype:'radiofield'
},
{
boxLabel: 'HP 2',
name: 'hps',
inputValue: 'hp2',
xtype:'radiofield'
}]
});
laptoptypes = Ext.create('Ext.form.ComboBox', {
store: laptops,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
editable:false,
width: 100,
onchange:onSelectChange(this),
});
只需设置value
的combobox
对应于从商店的值。因此,如果设置valueField
为'abbr'
,'abbr'
则可以使用存储的值之一。
laptoptypes = Ext.create('Ext.form.ComboBox', {
store: laptops,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
value: 'tosh',
editable:false,
width: 100,
onchange:onSelectChange(this),
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句