PDA

View Full Version : Textfield value changing



skaner
2 Nov 2009, 9:48 PM
Sorry for my english and buggy question :) I have a next code


items:[{
xtype:'form',
labelWidth: 100,
frame: true,
title: 'Auth form',
bodyStyle:'padding:5px 5px',
width: 320,
defaults: {
width: 190,
itemCls: 'required'
},
defaultType: 'textfield',
id:'AuthForm',
items: [{
fieldLabel: 'Login',
id: 'Login'
},{
fieldLabel: 'Password',
id: 'Password',
vtype: 'password',
inputType: 'password'
}],
buttons:[{
autoWidth:true,
text: 'OK'
},{
autoWidth:true,
text: 'Cancel',
listeners:{
'click': function(){
Ext.get('Login').reset();
}
}
}]


When I click 'Cancel' button, I get the message that 'Login' element doesnt contain method "reset()". What I did wrong? I need to clear or to change the fields on click event in this form.

tubamanu
3 Nov 2009, 12:20 AM
Ext.getCmp('Login').reset();

skaner
3 Nov 2009, 12:35 AM
Thanks, but it isnt work to ). In other side I was found the solution by myself: function Ext.get() returns Ext.Element - there is no setValue() method in it. I use next construction:

Ext.get('elementId').set({value: 'new value'})

Animal
3 Nov 2009, 1:28 AM
Ext.getCmp("Login").reset() will work if you give the "Login" field a value to begin with.

You should use a Component's methods to manipulate it, NOT underlying DOM methods. Changing the DOM state without changing a Component's state can lead to problems when the Component does not know about the state change and behaves as if the state was what it last know about.