PDA

View Full Version : access extjs components out of ext.onready



sistasi
8 Jun 2008, 11:50 PM
hi,

i saw this (http://extjs.com/forum/showthread.php?t=24067) for calling function from link, i have my link within grid ready to call a function outside ext.onready.
However within this function i need to hide the panel that i created within ext.onready.
Does anyone know how to access or call the ext component within ext.onready from the function outside ext.onready?


Ext.onReady(function(){

Ext.QuickTips.init();

function formatRoleName(value, p, record){
var str ='';
if (record.data.desc != ''){
str += value + '<br/><i>' + record.data.desc + '</i>';
}else{
str += value;
}
if (record.data.hideAssignDA == true){
str += ' <a href="javascript:doHideAssignDA(' + "'" + record.data.name + "'" + ')"><img src="' + iconpath + 'application_view_tile.png" border="0"/></a>'
}
return str;
}

var roleCM = new Ext.grid.ColumnModel([
roleChkCol,
{id:'name', header: "Role Name", width: 222, sortable: true, dataIndex: 'name', renderer: formatRoleName},
{header: "Application", width: 80, sortable: true, dataIndex: 'app'},
{header: "Type", width: 80, sortable: true, dataIndex: 'type'},
{header: "Source", width: 80, sortable: true, dataIndex: 'env'},
{header: "Description", width: 80, sortable: true, dataIndex: 'desc', hidden:true},
//roleExpander,
roleRowActions
]);

var roleGrid = new Ext.grid.GridPanel({
id:'roleGrid',
autoHeight: true,
store: roleStore,
cm: roleCM,
bbar: rolePgtb,
plugins: [roleChkCol, roleExpander, roleRowActions]
});

var daPanel = new Ext.Panel({
id:'da-panel',
frame:true,
...
});

}); //end of Ext.OnReady

function doHideAssignDA(Name){

if(daPanel.isVisible() == false){
Ext.getCmp('daText').body.update('<p style="margin:10px">Hi <b>' +
Name + '</b></p>');
daPanel.show();
} else{
daPanel.hide();
}
}

this will give error: daPanel is not defined, i think because daPanel is within Ext.OnReady and when I used Ext.getCmp('daPanel') will still give error:
Ext.getCmp("daPanel") has no properties
any idea how to do this??

hendricd
9 Jun 2008, 5:11 AM
To minimize scoping problem with components, use the actual component id you assigned:



function doHideAssignDA(Name){
var daPanel = Ext.getCmp('da-Panel');
if(daPanel.isVisible() == false){
Ext.getCmp('daText').body.update('<p style="margin:10px">Hi <b>' +
Name + '</b></p>');
daPanel.show();
} else{
daPanel.hide();
}
}

sistasi
9 Jun 2008, 7:53 PM
hendricd: it's not working.
I got this error: daPanel has no properties

hendricd
9 Jun 2008, 9:06 PM
I typed the wrong case, open your eyes and try again:


var daPanel = Ext.getCmp('da-panel');

sistasi
9 Jun 2008, 9:22 PM
oopz ic hehehe sorry....

yup it works... thanks a lot heheheh... i thot my id is the same hehe... :D