Results 1 to 5 of 5

Thread: Multiview and single store

  1. #1
    Sencha User
    Join Date
    Mar 2011
    Location
    Pavia, Italy
    Posts
    30
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You will need to have two different stores for this.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Mar 2011
    Location
    Pavia, Italy
    Posts
    30
    Answers
    1
    Vote Rating
    0
      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 User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    116
      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
      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 ...

Posting Permissions

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