Results 1 to 6 of 6

Thread: ViewController: get a window reference with lookupReference

  1. #1
    Sencha Premium User
    Join Date
    Jul 2014
    Posts
    269
    Answers
    15

    Default Answered: ViewController: get a window reference with lookupReference

    Hi!

    Can we get a window reference with lookupReference?

    The following example works well with itemId / Ext.componentQuery, but does not work with reference / lookupReference.


    Why?

    https://fiddle.sencha.com/#fiddle/e93

    Thanks in advance.

  2. Did you try getView() ?

    Code:
    var windowX = this.getView();

  3. #2
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    707
    Answers
    25

    Default

    Did you try getView() ?

    Code:
    var windowX = this.getView();

  4. #3
    Sencha Premium User
    Join Date
    Jul 2014
    Posts
    269
    Answers
    15

    Default

    Thanks carol.ext.

    I was convinced, wrongly, that 'reference' only worked with 'lookupReference'.

    Thanks again.

  5. #4
    Sencha Premium User
    Join Date
    Jul 2014
    Posts
    269
    Answers
    15

    Default

    Hi!

    Just one more little note to increase my knowledge.

    your suggestion works perfectly and is the solution that I will use.

    But it has nothing to do with Ext.Component.reference as lookupReference (
    get a reference to the component set with the Ext.Component.reference configuration)?
    This my perspective of the matter is correct?


    In this case 'getView ()' will not consults the cache?


    Only lookupReference consults cache?


    My doubts stem from the Extjs Guides say about reference:

    "This is similar to assigning an itemId of" fooGrid "and doing".. This.down ('# fooGrid') "The difference under the hood, However, is quite Significant First, the reference config instructs the component to register itself with its owning view (Identified by the presence of a ViewController in this case). Second, the method simply lookupReference Consults the cache to see if references need to be refreshed (say due to add or remove on the container). If all is well , it just returns the reference from the cache. "

    http://docs.sencha.com/extjs/5.0/application_architecture/view_controllers.html


  6. #5
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    707
    Answers
    25

    Default

    The view controller has a reference to the view where the controller is specified. That is what getView() returns. Code taken from source linked from API.

    Code:
    getView: function() {
            return this.view;
        },
    The example you refer to is dealing with a grid within the view where the controller is specified (the view is a panel with a grid as one of its items and with the reference specified).

    Now, take a look at what the viewcontroller's lookupReference does; it has the view do the lookupReference() :

    Code:
        lookupReference: function (key) {
            var view = this.view;
            return view && view.lookupReference(key);
        },

  7. #6
    Sencha Premium User
    Join Date
    Jul 2014
    Posts
    269
    Answers
    15

    Default

    Thanks for replying.

    Now I understand better this matter.

    Thank you again for your very valuable clarification and for helping me to advance on extjs with consistency.

Posting Permissions

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