How to reuse storage in an EXT JS 4 MVC application without multiple reboots?

I am working on an extjs 4 MVC application.

The application launches the Viewport, which contains a tabpanel. Each tab has its own controller and several types.

See my sandboxes at http://wap7.ru/folio/ext-reuseable-store/TE.html

I have one store that is used several times (for example, one tab in combobox topmenu, the other in the clietns grid). The store is configured with autoload: true. The proxy is configured in the model.

My problem: Store is loaded several times - at each mention in the controller array [stores].

If I delete one from the [stores] controller array, the combobox will be empty, although it will store store: Ext.getStore ('STORE-ID')

Please give me a hint or example of reusing Store (not Model), as here http://docs.sencha.com/ext-js/4-0/#!/guide/mvc_pt2

+5
source share
3 answers

You can simply create an instance of your store and download it, delete the autoload.

var store = Ext.create('App.store.YourStore').load();

Then transfer this storage to all your components, just as you would when you want the paging panel to connect to the grid.

+1
source

This works fine to call your store from other controllers:

Ext.getStore('PlatformClient');

I have never tried to put the same store in more than one controller array stores. It seems strange to me.

, , , , , , , , . :

-, " " :

models:[
'te.store.PlatformClient'

],

, , .

-, , , , . , ExtJS , , , , , . , "" , :

stores:[
    'Taxonomy',
    'PlatformClient',
    'DataType'
],
controllers:[
    'Taxonomies' ,
    'DataType' ,
    'DataSale' ,
    'Clients' 
],

.

, , , storeId MVC. :

storeId: [StoreClassName] 

, :

storeId: 'PlatformClient'

- MVC , , dev, storeId MVC .

0

. ( , ). . , , -, .

/**
* Use this for example if you want to apply a filter on a store
* but you dont want the original store to change, so:
* singleton store has no filter
* you clone it to be used with filters in some places.
*
* Note: this will have memory proxy, so no changes to the stores are persistent,
* changes will have no effect on the local/remote db.
*
*/
createStore: function(storeId, data) {

    //
    // Creates a new store from the given array of records without
    // registering the new store.
    // See cloneStore for more info
    //
    var modelName = storeId;
    var prevStore = Ext.getStore(storeId);
    data = data || prevStore.data.all;

    var clonedStore = Ext.create('App.store.' + storeId, {
        data: data,
        model: 'App.model.' + modelName,
        proxy: 'memory'
    });

    Ext.data.StoreManager.register( prevStore );

    return clonedStore;

}

, - . . , .

, .

0

All Articles