-
6 May 2011 3:42 AM #1
[EXTJSIV-1804]Ext.ComponentQuery.query() for ItemId's / xtypes containing '.'
[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.
-
10 May 2011 10:40 PM #2
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.
-
11 May 2011 4:38 AM #3
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
-
11 May 2011 5:22 AM #4
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)
-
11 May 2011 6:32 AM #5
vg Steffen
--------------------------------------
Release Manager of TYPO3 4.5
energlobe.de - german online magazine
-
11 May 2011 6:53 AM #6
oooh - that's (multiple confused view instances) a bad one...
-
11 May 2011 10:48 AM #7
Isn't this avoidable if an itemId is given or what do you mean with instance and usage of multiple views?
With ExtJs3 we queried with Ext.getCmp and the ID the defined now called view.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()
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.
-
12 May 2011 11:06 PM #8
I've opened up a ticket internally to review:
a) Whether CQ will support the "convenience" aliases
b) Whether we'll support periods in xtypesEvan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
16 May 2011 7:11 AM #9
This will cause problems with the ComponentQuery because .'s are references to components in ComponentQueryI 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.
From the Docs:
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).Components can be retrieved by using their xtype with an optional . prefix
- component or .component
- gridpanel or .gridpanel
-
16 May 2011 7:13 AM #10
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.
Similar Threads
-
Ext.ComponentQuery.query() not working
By ashish01 in forum Sencha Touch 1.x: DiscussionReplies: 3Last Post: 7 Sep 2012, 4:45 AM -
[OPEN-1062] Load Record by itemId doesn't work for composite fields
By zefciu in forum Ext 3.x: BugsReplies: 1Last Post: 24 Jul 2012, 12:57 PM -
Ext.ComponentQuery.query() only creates an empty array
By Reggae in forum Ext: DiscussionReplies: 5Last Post: 24 May 2011, 4:09 AM -
[OPEN-EXTJSIV-1804]Ext.ComponentQuery xtype
By rchloupe in forum Ext:BugsReplies: 0Last Post: 30 Apr 2011, 12:00 PM -
[OPEN-759] Ext.ComponentQuery.query() Epic Fail!
By gcallaghan in forum Sencha Touch 1.x: BugsReplies: 0Last Post: 3 Feb 2011, 5:50 PM


Reply With Quote
