日期:2014-05-16  浏览次数:20652 次

求解:ExtJs中在tbar里加combo时,出错。
代码如下:
xtype:'combo',
id:'one',
name:'one',
width:100,
fieldLabel:'Color',
anchor:'80%',
valueField : 'colorid',
displayField : 'colorname',
mode : 'local',
store : new Ext.data.SimpleStore({
fields: ['display', 'value'],
data : [
["Subs","subs"],
["Non-Subs","nonsubs"],
["all","all"]
]
}),
selectOnFocus : true,
editable : false,
allowBlank : false,
triggerAction : 'all',
loadingText : 'loading...',
listeners : { 
'select' : function(combo, record, index) {
Ext.getCmp('two').setVisible(true);
Ext.getCmp('three').setVisible(true);
}

出错信息:
  'undefined' 为空或不是对象 ext-core.js, 行15 字符40110
求助。

------解决方案--------------------
valueField : 'colorid',
displayField : 'colorname',
mode : 'local',
store : new Ext.data.SimpleStore({
fields: ['display', 'value'],
data : [
["Subs","subs"],
["Non-Subs","nonsubs"],
["all","all"]
]
}),
valueField 和 displayField 要和下面store中的fields对应
还有 
Ext.getCmp('two').setVisible(true);
Ext.getCmp('three').setVisible(true);
id为two和three的组件在哪呢?
温馨提示,先看看Extjs的书吧....
------解决方案--------------------
把东西分开写吧,看起来方便些
var sectionData=[
['Subs','subs'],
['Non-Subs','nonsubs']
];

var sectionStore=new Ext.data.SimpleStore({
fields:['display','value'],
data:sectionData
});

var sectionCombo=new Ext.form.ComboBox({
hidden:true,
fieldLabel:'区间比例显示',
id:"section",
displayField:'value',
valueField:'display', store: sectionStore,
triggerAction: 'all',
lazyRender:true,
width:100,
typeAhead: true,
selectOnFocus:true,
allowBlank:true,
mode:'local',
editable:true
});
注意的是 你自己给取 colorid,colorname,可是~·里面定义了 display,value。。。这里有个小小的问题,
另外还有楼上所说
id为two和three的组件在哪呢?
建议把代码填得全一点,这样比较好