1. #1
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Answered: Change view in sencha touch 2

    Answered: Change view in sencha touch 2


    I had make a controller in sencha touch 2 in which i am performing an ajax request.

    I want to change the view on suceess.

    Currently i am using
    var firststep = Ext.create('Myapp.view.Rangeselector'); Ext.getCmp('loginForm').destroy();
    Ext.Viewport.add(firststep);

    It is destroying loginForm but didn't load Rangeselector view.

    Can anyone please give me a solution.

  2. Hi deepakgarg89,

    try this:
    Code:
    var firststep = Ext.create('Myapp.view.Rangeselector');
    Ext.Viewport.setActiveItem(firststep);
    It's not enough to just add your view to the viewport, you already have to navigate to it

    Best regards,
    Schildi

  3. #2
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Change view in sencha touch 2

    Change view in sencha touch 2


    I had make a controller in sencha touch 2 in which i am performing an ajax request.

    I want to change the view on suceess.

    Currently i am using

    var firststep = Ext.create('Myapp.view.Rangeselector');
    Ext.getCmp('loginForm').destroy();

    Ext.Viewport.add(firststep);

    It is destroying loginForm but didn't load Rangeselector view.

    Can anyone please give me a solution.

  4. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      0  

    Default


    Hi deepakgarg89,

    try this:
    Code:
    var firststep = Ext.create('Myapp.view.Rangeselector');
    Ext.Viewport.setActiveItem(firststep);
    It's not enough to just add your view to the viewport, you already have to navigate to it

    Best regards,
    Schildi

  5. #4
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Hi Schildi,

    Hi Schildi,


    Thanks for reply, I will use it and than revert back on the same

  6. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Use setActiveItem method. You can use this method a couple different ways.

    You can pass it a component instance or a config object. If it's a config object it will create an instance. If the component instance (created by passing an instance or if it was created via a config object) isn't an item then it will add the instance to the parent. Once that happens then it will make it the active item and display it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Just noticed you posted the same question twice in 2 different forums. Please do not do this, I have merged the threads.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  8. #7
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Thanks for reply mitchell,

    Thanks for reply mitchell,


    I will take care in future and post only in one forum

  9. #8
    Sencha User
    Join Date
    Jun 2013
    Posts
    31
    Vote Rating
    0
    appz is on a distinguished road

      0  

    Default


    Hi, mitchell,

    I am new to Sencha Touch, please kindly advise the following questions regarding to the setActiveItem():

    1) As you mentioned, we may pass component instance or a config object to setActiveItem(), any performance difference regarding to such 2 approaches?

    2) As you mentioned, we may pass a config object to setActiveItem(), in that case, does it mean that a NEW instance of the corresponding component will be created whenever calling setActiveItem(), any performance impact ?

    3) Before passing component instance or a config object to setActiveItem(), is it necessary to destroy the current view ? My main concern is the performance and memory issue.

    4) If my application contains for example, 10 views, 5 of them are more frequently viewed, and the rest are less frequently viewed, which of the following approach i should use, any difference in the performance/memory impact ?

    Approach 1: Create ALL of the 10 views instance and add them all to the Viewport in app.js, and use setActiveItem( <index of active item> ) to show the releveant view instance when its being viewed.

    Approach 2: Create the view instance only when it is being viewed and then pass it to setActiveItem() to show it