Hybrid View

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    2
    Vote Rating
    0
    jreuben is on a distinguished road

      0  

    Default Unanswered: Resetting store's Proxy from localStorage to AjaxProxy

    Unanswered: Resetting store's Proxy from localStorage to AjaxProxy


    I wanted to check the saved record from the local storage and authenticate the record with the server. I tried to change the store proxy using the function setProxy. First time when i call setProxy on the store it works fine however when i call it second time with a different Proxy, it throws error "Cannot call method 'getRecords' of undefined". Below is the logic.

    localProxy = this.local = Ext.create('Ext.data.proxy.LocalStorage', {id:'credentials'});
    store.setProxy(localProxy);
    ...

    serverProxy = Ext.create('Ext.data.proxy.Ajax', { url: 'xxx',
    type:'json',
    });

    store.setProxy(serverProxy);
    on executing this statement, it throws error "Cannot call method 'getRecords' of undefined"

    Any help is much appreciated.

    Thanks,
    John

  2. #2
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    This is absolutely a problem with setProxy when switching between local and ajax proxies.

    Ext.apply.factory checks

    if (instance && instance !== config) {

    Where instance is your old proxy (the one your switching out of) and config is your new one (the one your requesting set in the setProxy call).

    If they're not equal (they aren't), it runs

    instance.destroy();

    The destroy method

    destroy: function(operation, callback, scope) {
    var records = operation.getRecords(),


    Attempts to immediately initialize records via operation.getRecords(), however there is no operation passed to the destroy function.

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    I believe the problem may be user error.

    I was seeing this error when doing

    //Original REST proxy
    var swap = this.getProxy();

    //localProxy: { type:'localstorage; id: 'foo'; }
    //...defined in the Model config

    this.setProxy(this.getLocalProxy());

    //Restoring the original proxy
    this.setProxy(swap);

    Though this appears correct/straightforward, the last line should actually read

    //Restoring the original proxy
    this.setProxy(swap.config);

    This eliminated the error above.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar