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.
  1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    26
    Vote Rating
    1
    Reggae is on a distinguished road

      0  

    Default [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.

  2. #2
    Sencha User
    Join Date
    Mar 2011
    Location
    Germany
    Posts
    198
    Vote Rating
    1
    Nickname is on a distinguished road

      0  

    Default


    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',
        
    constructorcn
    });

    Ext.define('Namespace_Panel', {
        
    extend'Ext.panel.Panel',
        
    alias'widget.alias_no_namespace_panel',
        
    constructorcn
    });

    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.

  3. #3
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    931
    Vote Rating
    53
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    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

  4. #4
    Ext JS Premium Member stevil's Avatar
    Join Date
    Nov 2007
    Location
    Denver, CO
    Posts
    1,045
    Vote Rating
    9
    stevil will become famous soon enough

      0  

    Default


    Quote Originally Posted by westy View Post
    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)

  5. #5
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    7
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    Quote Originally Posted by stevil View Post

    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

  6. #6
    Ext JS Premium Member stevil's Avatar
    Join Date
    Nov 2007
    Location
    Denver, CO
    Posts
    1,045
    Vote Rating
    9
    stevil will become famous soon enough

      0  

    Default


    oooh - that's (multiple confused view instances) a bad one...

  7. #7
    Sencha User
    Join Date
    Mar 2011
    Location
    Germany
    Posts
    198
    Vote Rating
    1
    Nickname is on a distinguished road

      0  

    Default


    Quote Originally Posted by steffenk View Post
    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',
                
    width100,
                
    height200
            
    },
            
    items: [{
                
    region'center',
                
    itemId'p1'
            
    },{
                
    region'west',
                
    itemId'p2'
            
    }]
        });
        
    this.callParent();
      }
    });

    = 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.

  8. #8
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,017
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  9. #9
    Sencha User
    Join Date
    May 2011
    Posts
    20
    Vote Rating
    0
    OuranosSkia is on a distinguished road

      0  

    Default


    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).

  10. #10
    Sencha User
    Join Date
    May 2011
    Posts
    20
    Vote Rating
    0
    OuranosSkia is on a distinguished road

      0  

    Default


    Quote Originally Posted by steffenk View Post


    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)

Similar Threads

  1. Ext.ComponentQuery.query() not working
    By ashish01 in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 7 Sep 2012, 4:45 AM
  2. Replies: 1
    Last Post: 24 Jul 2012, 12:57 PM
  3. Ext.ComponentQuery.query() only creates an empty array
    By Reggae in forum Ext: Discussion
    Replies: 5
    Last Post: 24 May 2011, 4:09 AM
  4. [OPEN-EXTJSIV-1804]Ext.ComponentQuery xtype
    By rchloupe in forum Ext:Bugs
    Replies: 0
    Last Post: 30 Apr 2011, 12:00 PM
  5. [OPEN-759] Ext.ComponentQuery.query() Epic Fail!
    By gcallaghan in forum Sencha Touch 1.x: Bugs
    Replies: 0
    Last Post: 3 Feb 2011, 5:50 PM

Thread Participants: 16