ExtJS Window常用方法
一、属性
plain:布尔类型,true表示强制与背景色保持协调,默认值为false。
resizable:布尔类型,用户是否可以调整窗体大小,默认值为true表示可以调整大小。
maxinizable:布尔类型,true表示显示最大化按钮,默认值为false。
maximized:布尔类型,true表示显示窗体时将窗体最大化,默认值为false。
closable:布尔类型,true表示显示关闭按钮,默认值为true。
bodyStyle:与边框的间距,如:bodyStyle:"padding:3px"。
buttonAlign:窗体中button的对齐方式(left、center、right),默认值为right。
closeAction:"close"释放窗体所占内存,"hide"隐藏窗体,建议使用"hide"
modal: true,//为模式窗口,后面的内容都不能操作(屏蔽)
二、方法
show:打开窗体。
hide:隐藏窗体。
close:关闭窗体。
三、事件
show:打开窗体时触法。
hide:隐藏窗体时触法。
close:关闭窗体时触法。
例子
function showAddPanel(){
var newwin = new Ext.Window({
//xtype: 'window',
title: "添加数据",
modal: 'true',
width:700,
height: 450,
contentEl : Ext.DomHelper.append(document.body, {
tag : 'iframe',
src : 'http://www.baidu.com',
height : "100%",
width : "100%"
}),
buttons: [{
id:'btnSave',
text:'保 存',
//handler:doSave,
disabled:false
},{
text: '取 消',
handler: function(){
newwin.hide();
}
}]
});
newwin.show(this);
}
//设置window 的 frompanel
function showAddPanel(){
var newwin = new Ext.Window({
xtype: 'window',
title: "添加数据",
modal: 'true',
width:700,
height: 450,
items:
addForm,
buttons: [{
id:'btnSave',
text:'保 存',
//handler:doSave,
disabled:false
},{
text: '取 消',
handler: function(){
newwin.hide();
}
}]
});
newwin.show(this);
}
//------addForm
var addForm = new Ext.FormPanel({
layout:'column',
items: [{
items: {
columnWidth:15,
layout: 'form',
border:false,
items: [
{
xtype:'textfield',
fieldLabel: ' 合同编号',
width:200,
name: 'contractno',
allowBlank:false
},
{
xtype:'textfield',
fieldLabel: ' 项目名称',
width:200,
name: 'projectname',
allowBlank:false,
blankText: '项目名称不能为空!'
}
,{
xtype:'textfield',
fieldLabel: ' 项目经理',
width:200,
name: 'projectmanager',
allowBlank:false
},
new Ext.form.DateField({
fieldLabel: ' 预计开始时间',
name: 'startTime',
width:200
//allowBlank:false
}),
new Ext.form.DateField({
fieldLabel: ' 实际开始时间',
name: 'RealStartTime',
width:200
//allowBlank:false
})
]
}
}, {
items: {
columnWidth:.15,
layout: 'form',
border:false,
items: [
{
xtype:'textfield',
fieldLabel: ' 项目编号',
width:200,
name: 'projectno',
allowBlank:false,
blankText: '项目编号不能为空!'
},{
xtype:'textfield',
fieldLabel: ' 项目简称',
width:200,
name: 'projectalias'
},
//{
//右边空一格
//},
{
xtype:'textfield',
fieldLabel: ' 开发经理',
width:200,
name: 'projectleader'
},
new Ext.form.DateField({
fieldLabel: ' 预计结束时间',
name: 'endTime',
width:200
//allowBlank:false
}),
new Ext.form.DateField({
fieldLabel: ' 实际结束时间',
name: 'RealEndTime',
width:200
//allowBlank:false
})
]
}
}]
});
//保存按钮事件
function doSave()
{
Ext.MessageBox.show({
msg: '正在保存数据, 请稍侯',
progressText: '正在保存中',
width:300,
wait:true,
waitConfig: {interval:200},
icon:'ext-mb-save',
nimEl: 'btnSave'
});
addForm.getForm().submit({
url:'../art/art_add.aspx',
method:'POST',
success: function(form, action){
Ext.MessageBox.hide();
Ext.MessageBox.alert('提示', '数据保存成功!');
newwin.hide();
ds.load({params:{start:0, limit:25}});
},
failure: function(form, action){
Ext.MessageBox.hide();
Ext.MessageBox.show({
title:'错误',
msg: '数据保存失败!',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
});
}
//art_add.aspx页面
protected string strJson = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
string title = Request.Form["title"];
try {
int i = DbHelperSQL.ExecuteSql("insert into hca_art (hca_art_title) values('" + title + "')");
if (i > 0)
{
strJson = @"{success: true}";
}
else
{
strJson = @"{success: false}";
}
}
catch(Exception ex)
{
string strMsg = ex.Message;
strJson = @"{success: false}";
}
Response.Write(strJson);
}
单列 常用
//------addForm
var addForm = new Ext.FormPanel({
labelWidth: 75,
bodyStyle:'padding:5px 5px 0',
items: [{
xtype:'textfield',
fieldLabel: '标题',
name: 'title',
width: 230,
allowBlank:false
},{
xtype:'textfield',
width: 230,
fieldLabel: '作者',
name: 'hca_art_author'
},{
fieldLabel: '内容',
name: 'hca_art_content',
//width: 600,
//height:450,
xtype:'htmleditor',
} ]
});
浙公网安备 33010602011771号