1. #1
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default Model Associations will not work for client proxies

    Model Associations will not work for client proxies


    I was trying to use model with associations on a flow that only use localstorage and I realized that it is impossible.

    HasMany association is forcing filtering remote. You can resolve this by passing in association config store:{remoteFiltering:false} but there is also forced modelDefaults with foreignKey: me.get(primaryKey), and this one is made like this:

    Code:
    modelDefaults[foreignKey] = me.get(primaryKey);
    
                    config = Ext.apply({}, storeConfig, {
                        model        : associatedModel,
                        filters      : [filter],
                        remoteFilter : true,
                        modelDefaults: modelDefaults
                    });
    So it is practically impossible to use HasMany association with client filtering and you will end having all the records in the associated model updated to have the associated.foreignKey = owner.primaryKey, because of the forced modelDefaults

    I guess it should be specified that Association are working only with remote filtering, so with server proxies. (at least by default)

  2. #2
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Some fixing (?)

    Code:
    hasMany: {
                model: 'MyApp.model.Book',
                autoLoad: true,
                foreignKey: 'id_author',
                store: {
                    remoteFilter: true,
                    modelDefaults: false,
                    proxy: {
                        type: 'maskingproxy',
                        maskedStore: 'Books'
                    }
                }
            }
    Code:
    Ext.define(
    'MaskingProxy',
     {
       extend:'Ext.data.proxy.LocalStorage',
       alias:'proxy.maskingproxy',
       config:{
          maskedStore:false,
       },
        read: function(operation, callback, scope) {
    	   
    	   var filters = operation.getFilters();
               
    	   var store = Ext.StoreManager.lookup( this.getMaskedStore() );
    	   store.clearFilter(true);
    	   store.setFilters(filters);
    
              //I know my store is loaded :P
    
    	  var rec = store.getRange(0,store.getCount()-1);
    	  operation.setSuccessful();
    	  operation.setCompleted();
    	  operation.setResultSet(Ext.create('Ext.data.ResultSet', {
                records: rec,
                total  : rec.length,
                loaded : true
            }));
            operation.setRecords(rec);
    	  callback.call(scope,operation);
    	  
    	}
     }
    );

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi