Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    13
    Vote Rating
    0
    dbora is on a distinguished road

      0  

    Default Switching between remote store and localstorage

    Switching between remote store and localstorage


    REQUIRED INFORMATION


    Ext version tested:
    • Sencha Touch 2.x
    Browser versions tested against:
    • Chrome
    • Android
    DOCTYPE tested against:
    • ____
    Description:
    • I am trying to switch between remotestorate and localstorage dynamically based on network connection.
    • I am using setStore() method of list to switch between stores.
    • I am defining store on list and before loading data, I am assigning store to list by using mylist.setStore(store)
    Steps to reproduce the problem:


    The result that was expected:


    The result that occurs instead:



    Test Case:


    Code:
         View: 
    
    Ext.define('MyApp.view.MyList', {extend: 'Ext.List',
    xtype: 'MyListView',
    config: {
    itemTpl: {info}
    
    }
    });
    
    Remote Store:
    
    Ext.define('MyApp.store.OnlineStore', {extend: 'Ext.data.Store',
    xtype: 'onlineStore',
    config: {
    autoLoad: false,
    
    clearOnPageLoad: false,
    
    model: 'MyApp.model.MyListModel',
    
    pageSize: 20,
    
    proxy: {
    
    type: 'jsonp',
    
    
    url: MyApp.util.Config.getServiceBaseUrl() + 'Data/GetInfo',
    
    
    reader: {
    
    
    type: 'json',
    
    
    
    rootProperty: 'Data',
    
    
    
    totalProperty: 'totalRecords'
    
    
    
    }
    
    
    }
    
    }
    });
    
    Local Store:
    
    Ext.define('MyApp.store.OfflineStore', {extend: 'Ext.data.Store',
    xtype: 'offlineStore',
    requires: [
    'Ext.data.proxy.LocalStorage'
    
    ],
    config: {
    autoLoad: false,
    
    clearOnPageLoad: false,
    
    model: 'MyApp.model.MyListModel',
    
    pageSize: 20,
    
    proxy: {
    
    type: 'localstorage',
    
    
    id: 'MyApp-OfflineStore'
    
    
    }
    
    }
    });
    
    
    Controller :
    
    //following is the logic to switch between stores on some event.
    
    if(isOnline){var myList = this.getMyList();
    var remoteStore = Ext.getStore('OnlineStore');
    myList.setStore(remoteStore );
    }
    else{var myList = this.getMyList();
    var offlineStore= Ext.getStore('OfflineStore');
    myList.setStore(offlineStore);
    }
    




    HELPFUL INFORMATION


    Screenshot or Video



    Possible fix:



    Additional CSS used:
    • only default ext-all.css

    Operating System:
    • Win 7

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    I think the dev team are going to want some more info, just a guess....!

    You'll need to post an example I would have thought.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    13
    Vote Rating
    0
    dbora is on a distinguished road

      0  

    Default


    View:

    Ext.define('MyApp.view.MyList', {
    extend: 'Ext.List',
    xtype: 'MyListView',
    config: {
    itemTpl: {info}
    }
    });

    Remote Store:

    Ext.define('MyApp.store.OnlineStore', {
    extend: 'Ext.data.Store',
    xtype: 'onlineStore',
    config: {
    autoLoad: false,
    clearOnPageLoad: false,
    model: 'MyApp.model.MyListModel',
    pageSize: 20,
    proxy: {
    type: 'jsonp',
    url: MyApp.util.Config.getServiceBaseUrl() + 'Data/GetInfo',
    reader: {
    type: 'json',
    rootProperty: 'Data',
    totalProperty: 'totalRecords'
    }
    }
    }
    });

    Local Store:

    Ext.define('MyApp.store.OfflineStore', {
    extend: 'Ext.data.Store',
    xtype: 'offlineStore',
    requires: [
    'Ext.data.proxy.LocalStorage'
    ],
    config: {
    autoLoad: false,
    clearOnPageLoad: false,
    model: 'MyApp.model.MyListModel',
    pageSize: 20,
    proxy: {
    type: 'localstorage',
    id: 'MyApp-OfflineStore'
    }
    }
    });


    Controller :

    //following is the logic to switch between stores on some event.

    if(isOnline){
    var myList = this.getMyList();
    var remoteStore = Ext.getStore('OnlineStore');
    myList.setStore(remoteStore );
    }
    else{
    var myList = this.getMyList();
    var offlineStore= Ext.getStore('OfflineStore');
    myList.setStore(offlineStore);
    }

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    So as I thought this is has been correctly marked as inforeq and it's not a bug!

    Read the docs before you post a bug report, you need to set the storeId, not the xtype, to be able to find the store using Ext.getStore.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    13
    Vote Rating
    0
    dbora is on a distinguished road

      0  

    Default


    I am able to get store correctly.
    issue is after setting store it is not reflecting in view.

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    Are you sure??? Look below, you're providing a string to Ext.getStore. So that string would have to correspond with a store id. You're not setting store ids on your stores, so I can't believe you're getting a store returned by your Ext.getStore calls.

    getStore( String/Object store ) : Ext.data.Store
    Shortcut to Ext.data.StoreManager.lookup.
    Gets a registered Store by id
    Parameters

    • store : String/ObjectThe id of the Store, or a Store instance, or a store configuration

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    13
    Vote Rating
    0
    dbora is on a distinguished road

      0  

    Default


    Yes I am getting store. as I am extending Ext.data.Store, we can get store by using Ext.getStore by providing class name

Thread Participants: 1

Tags for this Thread