52,780
社区成员
发帖
与我相关
我的任务
分享<html>
<head>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
</head>
<body>
<script>
Ext.onReady(function(){
var win=new Ext.Window({
title:'win',
width:300,
height:150,
labelWidth:35,
layout:'form',
items:[{xtype:'textfield',fieldLabel:'name'}],
plain:true,
buttons:[{text:'ok',handler:function(){alert(this.ownerCt.title)}}]
})
win.show();
})
</script>
</body>
</html>我用2.2.1的就是上面那样子的
看来版本不同这个ownerCt也不同
建议用win;alert(win.title);//建议这样用var win=new Ext.Window({
title:'win',
width:300,
height:150,
//labelWidth:35,window没有label,是formPanel的
layout:'form',
items:[{xtype:'textfield',fieldLabel:'name'}],
plain:true,
buttons:[{
text:'ok',
handler: function(){
alert(this.text);
alert(this.ownerCt.title);//v.2-2
alert(this.ownerCt.items.get(0).getValue());//v2.2
//alert(this.ownerCt.ownerCt.title);//v3 this.ownerCt是buttons容器,this.ownerCt.ownerCt才是window容器
//alert(this.ownerCt.ownerCt.items.get(0).getValue());//v3
}
}]
});
win.show();我测试了的,可以
ext v3版本的,源代码是copy我的就可以了
不要用你自己的,直接复制我的看看;Ext.onReady(function(){
var win=new Ext.Window({
title:'win',
width:300,
height:150,
//labelWidth:35,window没有label,是formPanel的
layout:'form',
items:[{xtype:'textfield',fieldLabel:'name'}],
plain:true,
buttons:[{
text:'ok',
handler: function(){
alert(this.text);
alert(this.ownerCt.ownerCt.title);//this.ownerCt是buttons容器,this.ownerCt.ownerCt才是window容器
alert(this.ownerCt.ownerCt.items.get(0).getValue());
}
}]
});
win.show();
});