value: '你的值'
Ext.onReady(function() {
var sexStore = Ext.create('Ext.data.Store', {
fields : ['code', 'name'],
data : [{
name : "男",
code : "M"
}, {
name : "女",
code : "F"
}]
});
var sexCombo = Ext.create('Ext.form.field.ComboBox', {
store : sexStore,
displayField : 'name',
valueField : 'code',
editable : false,
width : 200,
labelWidth : 60,
labelAlign : 'right',
fieldLabel : '性别',
value : 'F'
});
Ext.create('Ext.container.Viewport', {
layout : 'absolute',
items : [sexCombo]
});
});
请修改分类到 JavaScript 。 满意请采纳~
很简单 给你一段代码参考 值是后台服务器返回的 放到articleComboStore里面
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();