<html>
<head>
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="../extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../extjs/ext-all.js"></script>
<script type="text/javascript" src="../extjs/src/locale/ext-lang-es.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
var myform = new Ext.FormPanel({
layout: 'form',
padding: '10px',
items: [
{
xtype: 'textfield',
name : 'texto',
fieldLabel : 'Texto',
id: 'txt_target',
}
]
});
var myboton = new Ext.Button({
text: 'Presioname!',
listeners :{
click: function(){
var txt = Ext.getCmp('txt_target');
txt.setDisabled(true);
// o Ext.getCmp('txt_target').setDisabled(true); deberia funcionar igual
}
}
});
var mytoggleboton = new Ext.Button({
text: 'Deshabilitar',
enableToggle: true,
listeners :{
toggle: function(btn, value){
var txt = Ext.getCmp('txt_target');
txt.setDisabled(value);
switch(value){
case true :
btn.setText('Habilitar');
break;
case false :
btn.setText('Deshabilitar');
break;
}
}
}
});
var mywin = new Ext.Window({
title: 'Test Window',
layout: 'fit',
width: 300,
height: 120,
items: [
myform
],
bbar: [
myboton,
{xtype: 'tbfill'},
mytoggleboton
]
});
mywin.show();
});
</script>
</body>
</html>
MyWindowUi = Ext.extend(Ext.Window, {
title: 'Test Window',
width: 300,
height: 120,
layout: 'fit',
initComponent: function() {
this.items = [
{
xtype: 'form',
padding: '10px',
items: [
{
xtype: 'textfield',
fieldLabel: 'Texto',
name: 'texto',
ref: '../txt_target'
}
]
}
];
this.bbar = {
xtype: 'toolbar',
items: [
{
xtype: 'button',
text: 'Presioname!',
ref: '../btn_push'
},
{
xtype: 'tbfill'
},
{
xtype: 'button',
text: 'Deshabilitar',
enableToggle: true,
ref: '../btn_disabled'
}
]
};
MyWindowUi.superclass.initComponent.call(this);
}
});
MyWindow = Ext.extend(MyWindowUi, {
initComponent: function() {
MyWindow.superclass.initComponent.call(this);
this.btn_push.on('click', this.presioname, this);
this.btn_disabled.on('toggle', this.deshabilitar, this);
},
presioname: function(){
this.txt_target.setDisabled(true);
},
deshabilitar: function(btn, value){
this.txt_target.setDisabled(value);
switch(value){
case true :
btn.setText('Habilitar');
break;
case false :
btn.setText('Deshabilitar');
break;
}
}
});
<html>
<head>
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="../extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../extjs/ext-all.js"></script>
<script type="text/javascript" src="../extjs/src/locale/ext-lang-es.js"></script>
<script type="text/javascript" src="MyWindow.ui.js"></script>
<script type="text/javascript" src="MyWindow.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
var cmp1 = new MyWindow({
renderTo: Ext.getBody()
});
cmp1.show();
});
</script>
</body>
</html>
It looks like you're new here. If you want to get involved, click one of these buttons!
The content of this site is copyrighted by Quizzpot.com, it is prohibited to publish our tutorials on other blogs, magazines or any other media without prior permission.
Copyright © 2012 Quizzpot.
Our visitors are mostly developers and Web designers, advertise with us, you only need to contact us .