Results 1 to 3 of 3

Thread: Getting a component xtype path

  1. #1
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Phoenix, AZ
    Posts
    651
    Answers
    3
    Vote Rating
    14
      0  

    Default Getting a component xtype path

    Does anybody know of an efficient way to get the absolute path of a component's xtype that includes the parent hierarchy when given an element?

    For example, I have a viewport that contains an extended panel for authenticating (xtype: 'panel_login') that contains a button. If I catch an event that was targeted on the button element, I would like to be able to calculate that the path is "viewport panel_login button."

    This is one specific example but I'm looking for a generic pattern that could work for any element/component.

    Thanks!

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585
    Vote Rating
    394
      0  

    Default

    What do you mean by 'element'? Do you mean an HTML element or component?

    From the component it should just be this:

    Code:
    var comp = ...;
    var xtypes = [];
    
    while (comp) {
        xtypes.unshift(comp.getXType());
        comp = comp.ownerCt;
    }
    
    var path = xtypes.join(' ');
    From an HTML element things get much more complicated. In general there's no way to map from an element back to a component. You could approximate it but I can't think of an efficient algorithm for it.

    I'm a little unclear about why you would need to do this.

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Phoenix, AZ
    Posts
    651
    Answers
    3
    Vote Rating
    14
      0  

    Default

    I am trying to write some help documentation for my product. Since a given component may be used multiple times across different "applications," I am trying to uniquely identify the particular usage by the respective chain of xtypes. Since the help may be initiated by a key event, I have to start with the target element (html/ext) and go from there to get a component.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •