1. #1
    Sencha User
    Join Date
    Mar 2011
    Location
    Pavia, Italy
    Posts
    30
    Answers
    1
    Vote Rating
    0
    Cougar84 is on a distinguished road

      0  

    Default Answered: Multiview and single store

    Answered: Multiview and single store


    Hi there,
    I've a question about Stores & Views ...
    I'm trying to make a big application with a lot of view and stores and controllers.

    Here's my question:

    I usually create a controller when a "program" is called.
    This controller have n views and n store ...

    I'm trying to open the same view twice ( for example ) and there is a grid inside connected with a store ...
    thats the same because the view is the same ( but two instance ).

    Now what happend ... if I made a search in a view and than go to the other i saw the same records ...

    Thats because the store is the same ...

    Now, how can I avoid this problem?
    I mean ... it's my approach to the ExtJS system that is wrong for what i'm trying to do, or it's right and I have to change only something?

    Thanks,
    Marco

  2. You could implement initComponent() method for your view class. In there, you will create a new instance of store for your view, not use the store loaded by controller. Example:
    Code:
    Ext.define('Your view class', {
        ...
        initComponent: function(){
            var me = this;
            me.store = Ext.create('Your store class', {...});
            me.callParent(arguments);
        }
    })

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,604
    Answers
    3449
    Vote Rating
    818
    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


    You will need to have two different stores for this.
    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.

  4. #3
    Sencha User
    Join Date
    Mar 2011
    Location
    Pavia, Italy
    Posts
    30
    Answers
    1
    Vote Rating
    0
    Cougar84 is on a distinguished road

      0  

    Default


    But How if the view is the same?????
    That is my problem ...

    Controller "Pippo"

    Call View "Pluto" --> Store "Ciccio"
    Recall another instance of the View "Pluto" --> Store "Ciccio"

    How can I use two stores?
    There are 2 instance of the same view ... but not of the Store ... The store is the same ...

  5. #4
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    You could implement initComponent() method for your view class. In there, you will create a new instance of store for your view, not use the store loaded by controller. Example:
    Code:
    Ext.define('Your view class', {
        ...
        initComponent: function(){
            var me = this;
            me.store = Ext.create('Your store class', {...});
            me.callParent(arguments);
        }
    })

  6. #5
    Sencha User
    Join Date
    Mar 2011
    Location
    Pavia, Italy
    Posts
    30
    Answers
    1
    Vote Rating
    0
    Cougar84 is on a distinguished road

      0  

    Default


    Thats work ... but you loose the reference in the controller.

    this.getBlaBlaBlaStore() ...

    You have to put the ref by yourself on the component that use the store ...

Thread Participants: 2