加载本地数据(也就是下拉项是写死,或者是已知道的那种)
Ext.onReady(function() {
var logDataType = new Ext.data.SimpleStore({
fields : ['key', 'value'],
data : [['abc', '浏览记录'], ['def', '下载记录']]
});
var logTypeCombo = new Ext.form.ComboBox({
colspan : 2,
fieldLabel : '日志类型',
id : 'aaa',
store : logDataType,
displayField : 'value',
valueField : 'key',
mode : 'local',
typeAhead : true,
forceSelection : true,
triggerAction : 'all',
width : 155,
emptyText : '请选择 .... ',
selectOnFocus : true
});
var mainPanel= new Ext.Panel({
renderTo:document.body,
border:false,
width:300,
height:100,
items:[logTypeCombo],
buttons:[{
text:'button值',
handler:function(){
alert(logTypeCombo.value);
}
}]
})
logTypeCombo.setValue( logTypeCombo.store.getAt(0).get('key') ); //要让它默认选到第几个 把0 改成相应数字就好,超出会报错
});
?
加载服务器数据
var articleCombo = new Ext.form.ComboBox({
colspan : 2,
name : 'articleId',
fieldLabel : '学习内容',
displayField : 'value',
valueField : 'key',
store : articleComboStore,
mode : 'local',
typeAhead : true,
forceSelection : true,
triggerAction : 'all',
width : 355,
emptyText : '请选择 .... ',
selectOnFocus : true
});
articleComboStore.on("load",function(){ //对 ComboBox 的数据源加上 load 事件就好
articleCombo.setValue(this.getAt(0).get('key'));
});
articleComboStore.load();
?
?
?
?
?
?
?