ExtJS Combo默认值返回null
ExtJS Combo default value returned null
我已经在应用程序中设置了一个组合框。Combo具有emptyText
和我设置的默认值。
我希望保留'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
会发出警报吗?
// 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,
itemId: 'combo',
queryMode: 'local',
displayField: 'text',
valueField: 'id',
//emptyText: '7AM',
//value: '7',
renderTo: Ext.getBody(),
listeners: {
'select': function(cbo){
alert(cbo.getValue());
},
'afterrender': function(cbo) {
cbo.setValue("7");
}
}
});
你的例子似乎还可以。所以你的问题一定是在其他地方,而不是在组合本身。
1-检查应用程序的控制台中是否没有错误。
2-检查存储是否加载,当你检查它的值
3-检查是否有事件改变组合值后,它呈现
相关文章:
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 相同的RegExp返回不同的结果-第一次是正确的结果,第二次是null
- php函数的ajax html$_POST值返回null
- 谷歌地图API-“;toGeoJson”;返回几何体为null的对象
- 是否可以 document.getElementsByTagName('head')[0] ever 返回 null
- Firebase:查询返回null
- 在浅层渲染的反应组件上,Enzyme为道具返回null
- javascript对象显示为null,但object.properties返回数据
- PHP's json_decode返回空字符串(不是NULL)
- jQuery Multiselect插件返回null长度(应为0?)
- 如何处理getElementById返回Null
- JavaScript中的RegExp返回null
- node.js mongojs findOne回调返回错误为null
- Javascript 中的 RegEx 返回 Null
- 加载时的getelementbyID返回null
- 谷歌脚本在第二次调用Gmail后返回null
- Indexeddb OpenCursor在特定键值上返回null
- Ajax响应返回null
- null 返回 by JavaScript 中的 getElementById 方法
- 与typeof运算符一起使用时,javascript null返回对象