1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    2
    Vote Rating
    0
    nade is on a distinguished road

      0  

    Default Answered: Move between cards in card layout properly

    Answered: Move between cards in card layout properly


    I am using the following code to switch between my cards.

    Code:
    Ext.Viewport.setActiveItem({
        xtype: 'searchDetail'
    });
    Although on every call a new instance of this xtype seems to be created. What do I have to change to show the previously created instance of this xtype instead of creating a new one?

    Cheers,
    Nade

  2. If you pass in a config object which this is:

    Code:
    {
        xtype : 'container'
    }
    Then it will always create a new instance of that. If you want to switch to an already created instance, you should pass the index, id, or the instance of the item to setActiveItem...

    Code:
    var cnt = view.down('container');  //this uses ComponentQuery to resolve a container
    
    view.setActiveItem(cnt);

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3157
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    If you pass in a config object which this is:

    Code:
    {
        xtype : 'container'
    }
    Then it will always create a new instance of that. If you want to switch to an already created instance, you should pass the index, id, or the instance of the item to setActiveItem...

    Code:
    var cnt = view.down('container');  //this uses ComponentQuery to resolve a container
    
    view.setActiveItem(cnt);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    2
    Vote Rating
    0
    nade is on a distinguished road

      0  

    Default


    Thank you, I did it this way and it works properly. Do you have any suggestions to improve it, otherwise the ticket can be marked as solved.

    Code:
    var cnt = Ext.Viewport.down('searchDetail'); 
          if(cnt)
          {
            Ext.Viewport.setActiveItem(cnt);
          } else {
            Ext.Viewport.setActiveItem({xtype: 'searchDetail'});
          }

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3157
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Little better but you primarily had it!

    Code:
    var cnt = Ext.Viewport.down('searchDetail');
    
    if (!cnt) {
        cnt = {
            xtype : 'searchDetail'
        };
    }
    
    Ext.Viewport.setActiveItem(cnt);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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