You found a bug! We've classified it as
a bug in our system.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Sencha User
[EXTJSIV-1804]Ext.ComponentQuery.query() for ItemId's / xtypes containing '.'
I have a complex Application naming Objects according to an MVC approach. The xtypes of the objects get the same name as the object-name (e.g. 'MyApp.Domain.View.PersonView'). Same is done for the itemId's.
With Ext.ComponentQuery.query() I only get an empty Array when querying one of those Objects. When I change the ItemId to 'MyAppDomainViewPersonView', the query returns the Object as intented.
That should work for itemId's with '.' as well.
-
Sencha User
Have the same problem with namespaced aliases.
Example code:
PHP Code:
var cn = function() { // for demo, reduce LOC
console.info('Contructor: ' + this.alias);
this.callParent(arguments);
}
Ext.define('Namespace.Panel', {
extend: 'Ext.panel.Panel',
alias: 'widget.alias.with.namespace.panel',
constructor: cn
});
Ext.define('Namespace_Panel', {
extend: 'Ext.panel.Panel',
alias: 'widget.alias_no_namespace_panel',
constructor: cn
});
nsPanel = new Namespace.Panel();
// prints "Contructor: widget.alias.with.namespace.panel"
no_nsPanel = new Namespace_Panel();
// prints "Contructor: widget.alias_no_namespace_panel"
console.log(Ext.ComponentQuery.query('.alias.with.namespace.panel'));
// return empty array => []
console.log(Ext.ComponentQuery.query('.alias_no_namespace_panel'));
// return 1 element => correct
I don't know if this is a good way structure the alias with namespaces, but it seems consistent to all other organisation stuff built in into ExtJs4.
Relative bug reports:
Enable query on alias
Same Question, just one unnecessary demand
Please evaluate if this is a bug or wrong usage.
-
Heh, suspected that was the case so changed all my aliases to be more extish.
There are other issues with component query as well that we've spotted.
If you have more than one alias for a class you can only query by the first one, for example.
Cheers,
Westy
-
Ext JS Premium Member

Originally Posted by
westy
Heh, suspected that was the case so changed all my aliases to be more extish.
There are other issues with component query as well that we've spotted.
If you have more than one alias for a class you can only query by the first one, for example.
Cheers,
Westy
Alias definitely has the "feel" of xtype to me - it also has the limitation of not supporting (currently) class loading by alias - read: if the class with the alias is not loaded, you're OOL. Jacky Nguyen did leave me an encouraging post about a future unified factory pattern, though.
stevil
(not to be confused with St. Evil)
-

Originally Posted by
stevil
stevil
(not to be confused with St. Evil)

What also is not solved yet (just to mention) is having multiple instances of one view. Then you get multiple results and don't know which result belongs to which instance.
vg Steffen
--------------------------------------
Release Manager of
TYPO3 4.5
-
Ext JS Premium Member
oooh - that's (multiple confused view instances) a bad one...
-
Sencha User

Originally Posted by
steffenk
What also is not solved yet (just to mention) is having multiple instances of one view. Then you get multiple results and don't know which result belongs to which instance.
Isn't this avoidable if an itemId is given or what do you mean with instance and usage of multiple views?
PHP Code:
// demo view just to have a custom alias
Ext.define('My_Panel', {
extend: 'Ext.panel.Panel',
alias: 'widget.my_p'
});
// use the view 2 times
Ext.define('My_Window', {
extend: 'Ext.window.Window',
initComponent: function() {
Ext.apply(this, {
defaults: {
xtype: 'my_p',
width: 100,
height: 200
},
items: [{
region: 'center',
itemId: 'p1'
},{
region: 'west',
itemId: 'p2'
}]
});
this.callParent();
}
});
x = new My_Window();
x.show()
console.log(Ext.ComponentQuery.query('.my_p')); // all my_p instances
console.log(Ext.ComponentQuery.query('.my_p[itemId="p1"]')); // returns the center my_p panel
console.log(Ext.ComponentQuery.query('#p1')); // returns the center my_p panel, just like Ext.getCmp()
With ExtJs3 we queried with Ext.getCmp and the ID the defined now called view.
Alias is just the replacement of Ext.reg() (or what was it in Ext3?
) and we, well I did this, used Ext.getCmp() if the grid or whatever was not in the same scope or reachable via ownerCt attribute of a component.
-
I've opened up a ticket internally to review:
a) Whether CQ will support the "convenience" aliases
b) Whether we'll support periods in xtypes
Twitter - @evantrimboli
Former Sencha framework engineer, available for consulting.
As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.
-
Sencha User
I have a complex Application naming Objects according to an MVC approach. The xtypes of the objects get the same name as the object-name (e.g. 'MyApp.Domain.View.PersonView'). Same is done for the itemId's.
This will cause problems with the ComponentQuery because .'s are references to components in ComponentQuery
From the Docs:
Components can be retrieved by using their xtype with an optional . prefix
- component or .component
- gridpanel or .gridpanel
My guess is that when you have these complex names it's trying to look for components nested inside components where their xtype is each section between .'s (in your case it would be PersonView xtype's contained in View xtypes contained in Domain xtypes contained in MyApp xtypes).
-
Sencha User

Originally Posted by
steffenk
What also is not solved yet (just to mention) is having multiple instances of one view. Then you get multiple results and don't know which result belongs to which instance.
A view is supposed to represent a component type (similar in form to classes) where you give it ways to uniquely identify itself when you initialize it (like specifying an ID, or some other such attribute)