1. #1
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    France
    Posts
    4
    Vote Rating
    0
    sencha-dev1 is on a distinguished road

      0  

    Question Stores and ids conflict

    Stores and ids conflict


    Hi everyone,
    First,I apologize for all the mistakes i'm gonna write. English isn't my home language.


    I've got a little problems with some ids. I'm currently creating two panels using this:
    Code:
    var myPanel = new MyPanel();
    Ext.getCmp('myPanel' + localStorage.getItem('myId')).add(myPanel);
    This is working perfectly fine except for stores.
    In the Ext.define part of my panel, i wrote this:
    Code:
    store : 'myStoreId'

    The problem is that when I load the store on one panel, the other one is changing too. I find out that both stores have the same id.


    So i tried this:
    Code:
    store : Ext.create(Ext.data.Store, {
            autoLoad: false,
            autoSync: true,
            fields: ['myField', 'myOtherField', 'oneMore'],
            proxy: {
                type: 'ajax',
                actionMethods: {
                read: 'POST'
            },
            url: 'myController/aFunction',
            reader: {
                type: 'json',
                root: 'results'
            }
        }
    Thinking that dynamic ids will be different.
    Same problem, both stores are getting the same id. Something like 'ext-comp 3964'

    Does anyone know how to get different one?
    Thanks.
    -->

  2. #2
    Sencha Premium Member varsos's Avatar
    Join Date
    Feb 2008
    Location
    Long Island, NY
    Posts
    342
    Vote Rating
    15
    varsos will become famous soon enough

      0  

    Default


    From the Table.js:
    Code:
    me.store = Ext.data.StoreManager.lookup(me.store || 'ext-empty-store')
    So all of your panels use the same.
    Try:
    Make unique ids for the panel at create time:
    Code:
    Ext.create('MyPanel', {
      id: 'myPanelId'
    })
    then make unique store IDs in the initComponent of your panel, maybe like this:
    Code:
    initComponent: function(){
      this.store = Ext.create('Ext.data.Store', {
        storeId: this.id + '-myStoreId',
        . . .
     });
      . . .
      this.callParent(arguments);
      . . .
    Then you can lookup the stores using these ids and load them.
    varsos
    -->

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    France
    Posts
    4
    Vote Rating
    0
    sencha-dev1 is on a distinguished road

      0  

    Default


    Thanks for your answer but I can't give ids to my panels cause i need to create them dynamically.
    I found another solution that is perfectly working:
    In the store i wrote something like this:
    Code:
    Ext.define('MyPanel',{
    	storeId : 'myStoreId',
    	autoLoad: true,
    	autoSync: true,
    	fields: ['something','whatever'],
    	proxy: {
    		type: 'ajax',
    		actionMethods: {
    			read: 'POST'
    		},
    		url: 'aController/aFunction',
    		reader: {
    			type: 'json',
    			root: 'results'
    		}
    	}
    });
    I think that the Ext.define is making the difference here.

    In my panel, i wrote this:
    Code:
    store : Ext.create('MyPanel')
    Ext.define is creating some kind of model. Now, i can use Ext.create to make as much store as i need without id problems.
    -->

Thread Participants: 1

Tags for this Thread