PDA

View Full Version : extjs accessing component id



akosipotpot
11 Feb 2013, 10:08 PM
- - -I have 2 separate js file, and seems i cant access the component of first file to second file and vise versa
first file contains

Ext.define('ext.clientprofile.view.clientWindow', {
id:'clientWindow',
extend : 'Ext.window.Window',
title : 'Client Information',
height : 500,
width : 890,
x : 10,
y : 85,
maximizable : true,
constrain : true,
closeAction:'hide',
dockedItems : [ {
dock : 'top',
xtype : 'toolbar',
height : 30,
items : [ {id:'verify',iconCls: 'verifyButton',scale : 'large',},
{id:'test',iconCls: testButton',scale : 'large',handler:function(){
Ext.getCmp('verify').disable(); } //this absolutely works but
when i tried this to the other js file - seems nothing
}]
}],
items:{
id:'mytab',
region : 'center',
xtype : 'tabpanel',
minTabWidth : 75,
tabPosition : 'bottom',
items : [{
title:"CInfo",
id:'shouldHide',
html : 'This is a tabPanel'}]
}
});
second file contains

Ext.Loader.setConfig({ enabled: true });
Ext.Loader.setPath('ext', '../js/ext');
Ext.require(['Ext.form.*']);
Ext.require('ext.clientprofile.view.clientWindow');
Ext.onReady(function(){
Ext.create('ext.clientprofile.view.clientWindow');
var clientTypeSelect = Ext.create('Ext.form.field.ComboBox', {
id: 'clientTypeCombo',
typeAhead: true,
transform: 'clientTypeSelect',
width: 300,
forceSelection: true,
listeners : {
select : function(){
Ext.getCmp('clientTypeCombo').disable();
Ext.getCmp('verify').disable();
//whats the right way to disable the button with an id 'verify' from the 1st file :D
}
},
});
});

tnx in advance

mitchellsimoens
13 Feb 2013, 12:18 PM
As long as that button has been created it should work.

akosipotpot
13 Feb 2013, 6:20 PM
sad to say its not working - Ext.getCmp('verify').disable(); -> referring to the button from first file. maybe im just having a problem with the scope.
is there any way to access it aside from getCmp and ComponentQuery thank you for your time

mitchellsimoens
13 Feb 2013, 8:13 PM
It will work but if it isn't finding it, then the component is not created. You need to have an instance created, having the class definition doesn't mean it's created.

akosipotpot
14 Feb 2013, 12:15 AM
i pass it to a variable then try to identify what is it
var foo = Ext.getCmp('verify');
alert (foo);
it says [object Object]
what does it means?further explanation for this->"You need to have an instance created, having the class definition doesn't mean it's created"thanks alot