您的位置:首页 > Web前端 > JavaScript

ExtJs之下拉框

2017-06-13 17:43 85 查看
//下拉框store
var store = new Ext.data.Store({
autoLoad: true,
storeId: 'centerStore',
fields : ['id','name'],
proxy: {
type:'ajax',
url: url',
reader: {
type: 'json'
}
}
});
var addWin = Ext.create('Ext.window.Window', {
id: 'addWin',
width: 300,
height:300,
bodyPadding: 5,
maximizable: false,
monitorValid:true,
modal: true,
closeAction: 'hide',
listeners:{'close':function(){
cancelForm();
}
},
overflowX: 'hidden',
overflowY: 'auto',
items: [
Ext.create('Ext.form.Panel', {
id: 'userEngineForm',
width: 430,
url: url,
layout: 'anchor',
defaultType: 'textfield',
items: [{	//隐藏域
name: 'id',
hidden: true
},{
xtype: 'textfield',
fieldLabel:'ID',
name: 'userId',
disabled: true //不可编辑也不提交
},{
xtype: 'textfield',
fieldLabel:'用户账号',
name: 'account',
disabled: true
},{
xtype: 'combobox',             //使用xtype定义
name: 'engineId',                //form提交时的名称
id: 'eId',
fieldLabel: '请选择',        //显示的Label
store: store,               //绑定的Store
editable: false,               //是否可编辑
displayField: 'name',         //显示的字段
valueField: 'id',              //值的字段
queryMode: 'local'             //查询模式

}
]
})
],
buttons: [
{
text: '保存',
handler: function(){
var eId=Ext.getCmp('eId').getValue();
if(eId == '' || eId == null){
Ext.Msg.alert('系统错误提示', '请选择数据');
return;
}
Ext.getCmp('userEngineForm').submit({
waitTitle: '系统提示',
waitMsg: '保存中......',
success: function(form, action){
if(!action.result.success){
Ext.Msg.alert('系统提示', action.result.msg);
return;
}
//清空form表单
cancelForm();

Ext.Msg.alert('系统提示', '保存成功!', function(){
userEngineStore.reload();
});
},
failure: function(form, action){
Ext.Msg.alert('系统提示', action.result.msg);
}
});
}
},{
text: '取消',
handler: function(){
cancelForm();
}
}
]
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  extjs