PDA

View Full Version : Check if certain xtype exists/ is registered



michiel
9 Mar 2010, 10:22 AM
Hi guys,

I've been searching the forums for a while, but wasn't able to find the answer to my question whether it's possible to check if a certain xtype exists or is registered.

Basically I'm looking for something like this:



function foo(config) {

// xtype for a tree panel (based on module)
var my_xtype = config.module+'.treepanel';

// imaginary function, to see if the 'variable' xtype actually exists or not
if(!isRegisteredXtype(my_xtype)) {
// ok. the xtype with the module isn't registered, we use the default instead
my_xtype = 'default.treepanel';
}

var defaults = {
region: 'west',
items: {xtype: my_xtype}
}

// create config object
var cfg = Ext.apply({}, config, defaults);

// instantiate
var cmp = new Ext.Panel(cfg);

return cmp;
}



Ass you can see, I'm creating a panel with a tree panel inside it. I pass a module variable in the config. Then I want to see if there is a specific modified tree panel defined for this module. If there is, that one will be used. If it's not, a default tree panel will be used.

Does it exist in Ext? Is there an easy way to check for valid/ registered xtypes?

Thanks in advance. Michiel

Animal
9 Mar 2010, 11:02 AM
http://www.extjs.com/deploy/dev/docs/?class=Ext.ComponentMgr

michiel
9 Mar 2010, 11:20 AM
Great! Exactly what I had been looking for.

Thanks.