Results 1 to 3 of 3

Thread: Change a baseParams for 2 differents datastore

  1. #1
    Sencha Premium Member
    Join Date
    Nov 2011
    Location
    Compiegne FRANCE
    Posts
    48

    Default Change a baseParams for 2 differents datastore

    Hello All,

    I try to create 2 dataStores based on a same model and used by 2 differents grid. (The grids are used for drag and drop).

    This is the code of the data store object:

    Code:
    My.application.optionsListStore    =    Ext.extend(Ext.data.Store,
    {
         url        :    'myPage.php'
        ,baseParams    :
        {
            idDef         :    ''
            ,mode        :    ''
        }
        ,reader: new Ext.data.JsonReader (
        {
            root:'data'
        },[
              ,'DEF_OPTION_ID'
              ,'DEF_OPTION_NAME'
              ,'DEF_OPTION_DESCRIPTION'
        ]) // eof reader
        ,autoLoad:true
    }); // eof store
    And this is the both call to my object:

    Code:
            this.storeSelected         =    new My.application.optionsListStore({
                storeId    :    this.id + 'storeSelected'
                ,id    :    this.id + 'storeSelected'
            });
            
            this.storeSelected.baseParams.idDef        =    this.idDef;
            this.storeSelected.baseParams.mode        =    'selected';
           console.log('SELECTED = ' + this.storeSelected.baseParams.mode);
    
            this.storeExisting     =    new My.application.optionsListStore({
                storeId    :    this.id + 'storeExisting'
                ,id    :    this.id + 'storeExisting'
            });
    
            this.storeExisting.baseParams.idDef        =    this.idDef;
            this.storeExisting.baseParams.mode        =    'existing';
    
            console.log('EXISTING = ' + this.storeExisting.baseParams.mode);
            console.log('SELECTED = ' + this.storeSelected.baseParams.mode);
    The console.log return:
    SELECTED = selected
    EXISTING = existing
    SELECTED = existing

    So, when I load my store, I don't get the good data.

    I think I have a hole in my javascript object knowledges, if some one can help me to understand why the change on 1 object is reproduced to the second?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410

    Default

    You setting the baseparams in your parent class and then referencing it in 2 new objects.

    Have you look at setBaseParam() to set params dynamically for each. You may want to consider looking at extraParams as well.

    Scott.

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2011
    Location
    Compiegne FRANCE
    Posts
    48

    Default

    Hello Scott,

    Thank you for your answer, I replace my code for setting baeParams by 2 lines with myStore.setBaseParam.
    All it's ok now, and I found that the code is cleaner than several creation of very similares stores.


    Thank you for your help.

Posting Permissions

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