I'm building an MVC application in ExtJs 4.2 and there is a window and a formpanel.
Form panel has few hidden textfields which i want to show/hide.
When I run this commands:
Ext.getCmp('PartsSell').show();
or
Ext.getCmp('PartsSell').setVisible(true);
even
Ext.widget('ObjectForm').getForm().findField('PartsSell').setVisible(true);
nothing is happening!!
Here is formpanel snippet:
Ext.define('crm.view.ObjectForm', {
extend : 'Ext.form.Panel',
header : false,
alias : 'widget.ObjectForm',
url : 'action.php',
id : "ObjectForm",
defaultType : 'textfield',
initComponent: function() {
Ext.apply(this, {
items : [
{
fieldLabel : 'label',
labelWidth : 115,
hidden : true,
allowBlank : true,
name : 'PartsSell',
itemId : 'PartsSell',
xtype : 'textfield',
vtype : 'DigitsVtype',
width : 150,
padding : '0 0 0 15'
},
/* other stuff */]
} );
this.callParent(arguments);
}
} );
FF/chrome console behaves like everything is OK.
If i set 'hidden' param to 'false' the field is shown.
According to Tarabass and Drake advices:
I've changed id on itemId.
And now i can trigger field by
Ext.ComponentQuery.query('#PartsSell')[0].hide() / .show();
initComponentandExt.apply?id"PartsSell" (you might be callingshownot on the one you are looking at). Also note thatExt.widgetcreates new components so not fit to your purpose.ids within component classes is extremely bad idea.ids must be unique, and classes are supposed to be instantiated multiple times, so you already create the potential ofidcollision. If you have calledExt.widget('ObjectForm')at least twice you definitely have it.idonitemIdbut field 'PartsSell' is absolutely unque, andExt.widget('ObjectForm')is used only once, so the problem lies elsewhere...any thoughts?