1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    6
    Vote Rating
    0
    seawade is on a distinguished road

      0  

    Default Making new instance of a Store

    Making new instance of a Store


    Dear All,

    I'm not sure if I should post this question here or ExtJS4 forum, if this is not the place please let me know.. I am trying to create simple form panel using designer, and trying to -create- new store from store definition for treepanel (store def already made from designer) each time I create the form.

    From designer I can select the store for treepanel and all working however I am not sure how I can tell designer to create new store (instance) each time since I can't modify implementation class. As you can see, I'm new to ExtJS, Javascript, MVC.

    Where would I say something like..

    var store = Ext.create('somestore').. OR how do I use designer so that it will be effectively like:

    xtype: 'treepanel',
    itemId: 'CategoryTree',
    collapsed: false,
    store: Ext.create('somestore'), (instead of 'somestore')
    viewConfig: {
    rootVisible: false
    },

    If I change from store property of designer, it comes as store: 'Ext.create(\'somestore\')', instead..

    I'm trying to do all this just using designer 2.0 without hand modifying the source codes (which.. designer 2.0 overwrites).. if at all possible.

    Would I be doing such thing using controllers? or events?

    Thank you!

  2. #2
    Sencha User
    Join Date
    Mar 2008
    Posts
    6
    Vote Rating
    0
    seawade is on a distinguished road

      0  

    Default


    I somehow to got using controller...

    I think it will better describe what I'm trying to do.

    Code:
    if(tab) {
        console.log('found!');
    
        tab.show();
    } else {
        console.log('not found!');
    
        var product = Ext.create('Sample.view.ProductForm', {
            title: tabName,
            closable: true
        });
    
        var test = product.down('treepanel > dataview');
        var store = Ext.create('Sample.store.StoresCategories');
    
        console.log(test);
        console.log(store);
    
        test.bindStore(store);
    
        tab = panel.add(product);
        product.show();
    }

    ProductForm is a tabpanel which has form and inside of this form there is treepanel for selecting categories. There is also StoresCategories defined but I want to create new instance of store (as oppose to one I selected from designer as config value). Because whenever I am clicking a treenode, other treepanel reacts to click action instead of one that is clicked. I am guessing it's because of using same store...

    Any pointers will be very appreciated!

  3. #3
    Sencha User
    Join Date
    Mar 2008
    Posts
    6
    Vote Rating
    0
    seawade is on a distinguished road

      0  

    Default


    While I am trying everything I could try, I found just creating new store instance by

    var whateverstore = Ext.create('Sample.store.StoresCategories');

    just before I create the form (with tree), seems like making it to use newly created store. (without adding whateverstore anywhere). Now clicking the node does not affect other treepanel that's using SotresCategories.

    Code:
    var whateverstore = Ext.create('Sample.store.StoresCategories');
    
    var product = Ext.create('Sample.view.ProductForm', {
            title: tabName,
            closable: true
    });
    I have no idea but seems like Form (with tree) is using -last- created instance of StoresCategories?

    I can work with this but is this right way of using it or will it continuously make stores until memory fills up as I use the application and make and destroy forms?

    Thanks!

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,369
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    You've raised a lot of good points here that we are discussing internally before giving you response.

    Just want to make sure you don't feel neglected
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    72
    Vote Rating
    2
    mehran is on a distinguished road

      1  

    Default


    As a user who follows this thread, it's been more than a month since the last post on this thread whilst both Sencha Architect and ExtJS have gone under major releases (Sencha Architect 2 and ExtJS 4.1 are out now) and I wonder if this issue has been addressed in any of the releases.
    I've had the same problem with Sencha Architect for a while now. It doesn't support inline stores. One can not instantiate a new store for a component which means using global stores are mandatory. As for the grids it's possible to replace their store later (programmatically) using "reconfigure" method but trees do not have such a method! And thus it's a deadlock.
    Please let us know if any solution is made available.

    Regards,

  6. #6
    Sencha User
    Join Date
    Aug 2011
    Posts
    68
    Vote Rating
    2
    MaciejZabielski is on a distinguished road

      0  

    Default


    Well, I guess we are neglected here with this problem. I'm prototyping ExtJS application (4.1 + Architect 2).
    We will most likely not use Architect at all, but now, it looked like a good idea to keep app organized as Architect wants it just to make it right MVC.

    I have the same situation, where I want to add several tree panels to the same application view. Each works the same way, so they could use the same controller with view context. But each is using different data, that might contain the same objects arranged in different way. Since we would have one controller instance, I would have to create Store instance in each view instance. In Architect I can only select store from class list. There is no way to add store creation to initComponent (or I can't see how) and I guess that is very good place to do that.

    Second option would be to add Ext.create to "store"?

    Not everybody lives in a perfect world, where we have one simple view with one "products" list and static layout

  7. #7
    Sencha User
    Join Date
    Nov 2012
    Posts
    7
    Vote Rating
    1
    lxu is on a distinguished road

      0  

    Default Any update from the dev team on this feature?

    Any update from the dev team on this feature?


    I too like to have { store: Ext.create() } available in Architect

  8. #8
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,369
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    It's on the list of thigns to look at but hasnt gotten the attention it needs.

    We will look at it after the 2.2 release.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  9. #9
    Sencha User
    Join Date
    Nov 2007
    Posts
    52
    Vote Rating
    0
    boonkerz is on a distinguished road

      0  

    Default


    Code:
    var row = panel.items.getByKey('myshipping' + record.raw.id);
        if(row) {
        }else{
            this.getMyTabPanel().add({
                closable: true,
                xtype: "MyShipping",
                id: 'myshipping' + record.raw.id,
                title: record.raw.shopTitle + ' - Versandart'
            }).show();
            Ext.getCmp('myshipping' + record.raw.id).reconfigure(Ext.create('MyApp.store.MyShippingStore'));
            Ext.getCmp('myshipping' + record.raw.id).store.proxy.extraParams.shopId = record.raw.shop;
            Ext.getCmp('myshipping' + record.raw.id).store.load();
        }

  10. #10
    Ext JS Premium Member smcguire36's Avatar
    Join Date
    Sep 2007
    Location
    Manchester, Connecticut, USA
    Posts
    99
    Vote Rating
    0
    smcguire36 is on a distinguished road

      0  

    Default


    Has this issue been addressed in Sencha Architect 3?

    I too have a need for each new instance of a form (that contains embedded grids) that I instantiate to get its own instantiated COPIES of the stores the grids use. I am instantiating a form and adding it as a tab in a tab panel. I can add any number of the same form to the tab panel. Each form will contain a unique set of data so they cannot use the same copies of the stores.

    Stewart McGuire
    Ext JS 2.x, 3.x, 4.x - Advanced User / Sencha Architect 3 - User