0
我在我的应用程序中设置了一个ComboBox。组合有emptyText
和我设定的默认值。ExtJS Combo默认值返回null
我希望保留'7AM'文本和'7'作为默认值。但是当我尝试通过选择'7AM'来提交页面时,则返回值null
。
// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields : [
'id',
'text'
],
data: [
{
'id':'3',
'text':'3AM'
},
{
'id':'4',
'text':'4AM'
},
{
'id':'5',
'text':'5AM'
},
{
'id':'6',
'text':'6AM'
},
{
'id':'7',
'text':'7AM'
}
]
});
// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'text',
valueField: 'id',
emptyText: '7AM',
value: '7',
renderTo: Ext.getBody(),
listeners: {
'select': function(cbo){
alert(cbo.getValue());
}
}
});
上面是测试代码,你可以建议为什么当我选择7AM
null
被惊动?
您是否发布了如何提交组合详细信息的代码? – Saloo
您可以查看上面的代码。当您选择7AM时,它会提醒您null null –
我已经在ExtJS 4中运行了此代码,并且我没有收到空值。首先7AM已经被选中,所以即使你选择7AM,它也不会触发事件。当我选择其他号码时,我获得了适当的价值。然后我再次选择7AM,我得到7作为警报值。 – Saloo