1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    15
    Vote Rating
    0
    sbruck is on a distinguished road

      0  

    Default Understanding ComponentQuery and accessing peer components

    Understanding ComponentQuery and accessing peer components


    Using Architect 2, I have been able to create controllers, references (using ID), and controller actions. I run into trouble when I create two peer panels (panel1 and panel2) in the project. Neither is a child of the other (both are class level).

    I can create a button on panel1 and give it custom property of [action=gotopanel2]. If I create references for each panel then my understanding is that I then have a getPanel1 and a getPanel2.

    I have not been able to figure out how to instantiate panel 2 from panel 1. So far I have tried the following code in the controller action for the button:

    this.getPanel2().animateActiveItem(0,
    {type: "slide",
    direction: "left"}
    );

    The error I get is:

    Uncaught TypeError: Cannot call method 'animateActiveItem' of undefined

    I guess I figured that the reference would work regardless of whether the component was a parent, I have seen some discussion of the fact that by using ID, I benefit from a global search of the DOM. from the error message the componentquery seems not to be finding the other panel. I would appreciate it if anyone could set me straight. Thanks in advance!

    PS. Not sure whether it makes any sense to try and do this. I understand that navigation view may provide better method for doing this if all panels were nested beneath Navigation View...

  2. #2
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,738
    Vote Rating
    51
    Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough

      0  

    Default


    In order to do this you would have the controller manage the switch between one panel to the next.

    You could have an controller action that responds to a click event on panel1 and then spawns a new panel2. In no way should panel1 ever know about panel2.

    There are also times when you might want panel1 to simply fire an event on the application. The application would then respond by doing something (e.g. spawning a new panel2).

    Hope this is helpful.
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

  3. #3
    Sencha - Architect Dev Team jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    423
    Vote Rating
    15
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    It's not clear from your description, but it sounds like you're expecting the getPanel2() accessor to automatically instantiate the second panel? This should work, but you have to define the autoCreate and xtype in your refs config, otherwise it doesn't know how to create it.

    See http://docs.sencha.com/touch/2-0/#!/...oller-cfg-refs
    Jason Johnston
    @lojjic
    Sencha Architect Development Team

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    15
    Vote Rating
    0
    sbruck is on a distinguished road

      0  

    Default A few follow up questions... including how does forceCreate differ from autocreate?

    A few follow up questions... including how does forceCreate differ from autocreate?


    Thanks so much for the quick reply. I used your advise and was able to get the second panel to render.


    In order for this to work, I updated the controller reference for the panel2 to check Autocreate and I defined the xtype.


    For the Xtype I used the alias that I gave to the second panel, I did this because if I simply used xtype as panel, then I get a blank panel.


    For my controller action to render panel2 on the button click, I used a single line of code


    this.getPanel2().show();




    A couple of follow up questions:


    1) does the first panel automatically get destroyed? I have been accepting the default in architect of autodestroy for all objects.


    2) In the Javascript console I see a message which tells me that my simple one-line method for rendering panel2 is deprecated The message I get is


    "Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component); "


    Based on this message, can you suggest the complaint method of rendering panel2 compared to the above approach? I know the error message suggests the coding, but I have been unable to get it right.


    3) I have been looking for some discussion of what forceCreate does but have been unable to find it. just curious, can you point me to documentation for this? when would forcecreate be used over autocreate?




    Overall, Thanks very much for your help! I wasn't able to find any previous forum questions that were relevant to this, so your help was very valuable.

  5. #5
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,738
    Vote Rating
    51
    Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough

      0  

    Default


    I'm glad you got further in dev! I'm not sure forceCreate exists.

    In general for Touch you're going to want to be adding/removing things to a viewport or a navigationView. This will help manage the creation and destruction of your views.
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

  6. #6
    Sencha User
    Join Date
    Apr 2012
    Posts
    15
    Vote Rating
    0
    sbruck is on a distinguished road

      0  

    Default Viewport has me trying to find it in Architect

    Viewport has me trying to find it in Architect


    Phil,

    Thanks for your help, it was nice to progress, JJohnston was right, and he clued me in to the autocreate option which helped me get further. but then I get the viewport message (see below).

    In Architect, I am using Sencha Touch 2.1 (I figured I would try and use the most up to date framework)

    I cannot find any component for Viewport. I do see the navigation view. how would i use viewport as a top level container in architect using Touch 2.1?

    Also, when I do

    this.getPanel2().show();

    the Javascript console shows a message which tells me that my simple one-line method for rendering panel2 is deprecated The message I get is


    "Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component); "

    Any advice on how I can update my code to avoid this message?

    My understanding is that navigationview has a bunch of features (that I may not use), and I guess I was thinking that by avoiding navigationview I could get better performance and maybe a bit more control over the title bar. This resulted in having a panel as the initial view, and other panels as top level peers...

    Thanks again!

  7. #7
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,738
    Vote Rating
    51
    Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough

      0  

    Default


    You should be able to reference the main viewport with

    Ext.Viewport
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

  8. #8
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,738
    Vote Rating
    51
    Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough

      0  

    Default


    Perhaps autoCreate does not add it to the viewport and you need to call

    Ext.Viewport.add(panel2);

    before you call show on it?
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

  9. #9
    Sencha User
    Join Date
    Apr 2012
    Posts
    15
    Vote Rating
    0
    sbruck is on a distinguished road

      0  

    Default more progress, but one last question

    more progress, but one last question


    Phil,

    OK, I found the viewport component in architect 2. I was able to get the panel to display in the viewport without having to label any panel as "initial view." I added a viewport to the application node, and the following works from loader function by referencing the panel by its alias (xtype).

    Ext.Viewport.add({
    //xclass: 'Myapp.view.Panel2'
    xtype: 'mypanel2'
    });

    When I try to display it using a controller reference, it does not work, even when autocreate is checked for the reference.This does not work using getter for controler reference:

    var loc = this.getMainviewref();
    Ext.Viewport.add(loc);

    not sure why the controller reference does not work when autocreate is checked but no view is listed as initial view and I manually instantiate the initial view component in the launch method.

    Thanks for your help!

  10. #10
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,738
    Vote Rating
    51
    Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough Phil.Strong is a jewel in the rough

      0  

    Default


    I've never been a huge fan of the autoCreate on controller reference. Most of the time I need to pass one or more pieces of information into the config at run time anyways so this method is void.

    It sounds like you're moving on to what really matters which is the actual functionality of your app. Good luck!
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar