{
id :'editSendStatus',
xtype : 'combo',
fieldLabel : '发送状态',
displayField: 'name',
mode:'local',
valueField: 'key',
allowBlank : false,
editable :false,
<strong>store: Ext.create('Ext.data.Store', {
fields: ['key', 'name'],
data : [
{key:"0", name:"不发送"},
{key:"1", name:"发送"}
]
}),
<span style="color:#cc0000;">listeners:</span></strong>{
// afterRender:function(combo){
// //设置下拉列表值
// <strong>combo.setValue(selectData[0].get("stamp_status"));</strong>//同时下拉框会将与name为firstValue值对应的text显示
// } ,
<strong>select:function(combo){
if(combo.getRawValue()=="发送"){
parent.parent.Ext.getCmp('check_send_status').setDisabled(false);
}
if(combo.getRawValue()=="不发送"){
parent.parent.Ext.getCmp('check_send_status').setDisabled(true);
}
}</strong>
}
},{
id :'check_send_status',
xtype : 'combo',
fieldLabel : '签章检查',
displayField: 'name',
mode:'local',
valueField: 'key',
disabled :'true',
allowBlank : false,
editable :false,
store: Ext.create('Ext.data.Store', {
fields: ['namekey', 'name'],
data : [
{key:"0", name:"否"},
{key:"1", name:"是"}
]
})
,
listeners:{
afterRender:function(combo){
//设置下拉列表值
//Ext.getCmp('check_send_status').getRawValue()
combo.setValue(selectData[0].get("check_send_status"));//同时下拉框会将与name为firstValue值对应的text显示
}
}
}]
});
这段代码非常经典:
需要掌握的东西:1)combo怎么创建
2)对于这两个combo,第一个下拉列表默认的是不发送的,第二个下拉列表是不可编辑的,我们在第一个combo设置了listener事件,里面还有个select事件,当select事件会触发是否让第二个combo可编辑.第二个combo中有个afterRender是渲染事件
3)设置默认的的combo的值:combo.setValue(selectData[0].get("check_send_status"));
4)在一个combo中获得另外一个combo的内容,或者相关属性:parent.parent.Ext.getCmp('check_send_status').setDisabled(false);
关于更多的理解参考:http://blog.youkuaiyun.com/itjavawfc/article/details/41129957
下面看看一个从数据库中加载数据到前台的combox中去:
实现的效果:服务器名称为combox
var <strong>Service_store</strong>= Ext.create('Ext.data.Store', {
fields : ['group_id', 'group_name'],
proxy: {
type: 'ajax',
url : '/realware/common/queryConfig.action?para='+(this.para+"_service"),
reader: {
root : 'data',
type: 'json'
}
}
});
Service_store.load({
method : 'post',
params : {
field : "group_id,group_name"
}
});
// Create the combo box, attached to the states data store
var signcombo_service=Ext.create('Ext.form.ComboBox', {
id:'sign_service_id',
fieldLabel: '服务名称',
store:<strong> Service_store</strong>,
disabled:true,
emptyText:name_test, //'签名服务选项',
queryMode: 'remote',
displayField: 'group_name',
valueField: 'group_id',
labelAlign:'left',
labelWidth:220,
width:600
});
var sign_label=Ext.create("Ext.form.Label",{
labelWidth:200,
width:600,
style:'color:blue',
text:"请选择需要配置的服务"
});
this.groupPanel.add([signcombo_service]);
this.groupPanel.add([sign_label]);
}