Extjs 简单UI设计1

1: button
<script type="text/javascript">
Ext.onReady(function() {
new Ext.Button({
renderTo:Ext.getBody(),
text:"确 定",
minWidth:200,
handler:function() {
alert("handler 句柄相应button的默认事件:click");
}
})
});
</script>

<script type="text/javascript">
Ext.onReady(function() {
new Ext.Button({
renderTo:Ext.getBody(),
text:"确定",
minWidth:200,
listeners:{
"click":function() {
alert("listeners 自定义响应事件名称");
}
}
})
});
</script>


<script type="text/javascript">
Ext.onReady(function() {
var _button = new Ext.Button({
renderTo:Ext.getBody(),
text:"确定"
});

_button.on("click",function(){
alert("类实例的 on 方式 注册监听器")
});
});
</script>



2:textField
<script type="text/javascript">
Ext.onReady(function() {
var _panel = new Ext.Panel({
renderTo:Ext.getBody(),
layout:"form",
labelWidth:30,
listeners:{
"render":function(_panel){
_panel.add(new Ext.form.TextField({
id:"txt_name",
fieldLabel:"姓名"
}))
}
}
}) ;


new Ext.Button({
text:"确定",
renderTo:Ext.getBody(),
handler:function(){
alert(Ext.getCmp("txt_name").getValue());
}
})

});
</script>


3:panel
<script type="text/javascript">
Ext.onReady(function() {
var _panel = new Ext.Panel({
title:"人员信息",
frame:true,
width:200,
height:300
});

_panel.addButton({text:"确定"});
_panel.addButton(new Ext.Button({text:"取消",minWidth:100})) ;
_panel.render(Ext.getBody());
});
</script>

居中效果:
<style type="text/css">
.contain{
width:100% ;
height:100%;
top:0;
left:0;
}
.center{
position:absolute;
top:30%;
left:43%;
text-align:left;
}
</style>

<script type="text/javascript">
Ext.onReady(function() {
var _panel = new Ext.Panel({
title:"人员信息",
frame:true,
width:200,
height:300
});

_panel.addButton({text:"确定"});
_panel.addButton(new Ext.Button({text:"取消",minWidth:100})) ;

_panel.applyToMarkup(Ext.DomHelper.append(Ext.getBody(),{
tag:"div",
cls:"contain",
cn:[{
tag:"div",
cls:"center"
}]
},true).child("div")) ;
});
</script>

_panel.add({xtype:"textfield",fieldLabel:"姓名"});
<script type="text/javascript">
Ext.onReady(function() {
var _panel = new Ext.Panel({
title:"人员信息",
frame:true,
width:270,
height:130,
layout:"form",
listeners:{
"render":function(_panel){
_panel.add({xtype:"textfield",fieldLabel:"姓名"});
_panel.add(new Ext.form.TextField({
id:"txt_address",
fieldLabel:"地址"
}));
}
}
});

_panel.addButton({text:"确定"});
_panel.addButton(new Ext.Button({text:"取消",minWidth:100})) ;

_panel.applyToMarkup(Ext.DomHelper.append(Ext.getBody(),{
tag:"div",
cls:"contain",
cn:[{
tag:"div",
cls:"center"
}]
},true).child("div")) ;
});
</script>

2.0之后新式写法
<script type="text/javascript">
Ext.onReady(function() {
var _panel = new Ext.Panel({
title:"登录",
frame:true,
width:260,
height:130,
layout:"form",
labelWidth:40,
defaults:{xtype:"textfield",width:180},
items:[{fieldLabel:"帐号"},{fieldLabel:"密码"}],
buttons:[{text:"确定"},{text:"取消"}]
});

_panel.applyToMarkup(Ext.DomHelper.append(Ext.getBody(),{
tag:"div",
cls:"contain",
cn:[{
tag:"div",
cls:"center"
}]
},true).child("div")) ;
});
</script>

4:window
<script type="text/javascript">
Ext.onReady(function() {
var _window = new Ext.Window({
title:"登录",
frame:true,
plain:true,
resizable:false,
buttonAlign:"center",
width:260,
height:130,
layout:"form",
labelWidth:40,
closeAction:"hide",
defaults:{xtype:"textfield",width:180},
bodyStyle:"padding-top:6px;padding-left:6px",
items:[{fieldLabel:"帐号"},{fieldLabel:"密码"}],
buttons:[{text:"确定"},{text:"取消",handler:function(){
_window.hide();
}}],
listeners:{
"show":function(){
alert("show is happened!");
},
"hide":function(){
alert("hide is happened!");
},
"close":function(){
alert("close is happened!")
}
}
});
_window.show();
});
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值