1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    9
    Vote Rating
    0
    EdPS is on a distinguished road

      0  

    Default Extending a Store

    Extending a Store


    I have 4 stores just like the ones shown in the code below, where the only change between them is a single string variable that is applied in many parts of the code (in this case 'events') that is used for url of the call the rootProperty and the Id of the store.

    Code:
    Ext.define('MyApp.store.Events', {
        extend: 'Ext.data.Store',
    	
    	config: {
            model: 'MyApp.model.InfoBit',
            //groupField: 'fullTitle',
    		
    		//storeId: this.listKey,
    		storeId: 'events',
    		proxy: {
    			type: 'ajax',
    			//url : 'db/pull-infobits.php?listType='+this.listKey,
    			url : 'db/pull-infobits.php?listType=events',
    			reader: {
    				type: 'json',
    				//rootProperty: this.listKey
    				rootProperty: 'events'
    			}
    		},
    		autoLoad: true,		
        }
    	
    	/*constructor: function(config){
    		this.initConfig(config);
    	}   */
    });
    Is there way to extend a store class such that this value is a variable and I don't have to create 3 more clones of this code just changing those values? I am trying to create a more compact code. I want to create a single class that extends Ext.Store with the code above, putting the values that change as a variable, and then four small classes that extend this base class and define the value of the variable for the base class. Is this possible?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,731
    Vote Rating
    754
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    So have a base class like this:

    Code:
    Ext.define('MyApp.store.Abstract', {
        extend : 'Ext.data.Store',
    
        config : {
            model        : 'MyApp.model.InfoBit',
            rootProperty : 'events',
            autoLoad     : true,
            proxy        : {
                type   : 'ajax',
                url    : 'db/pull-infobits.php?listType=events',
                reader : {
                    type : 'json'
                }
            }
        },
    
        applyProxy : function(proxy, oldProxy) {
            proxy.reader.rootProperty = this.getRootProperty();
    
            return this.callParent([proxy, oldProxy]);
        }
    });
    And you should be able to extend like:

    Code:
    Ext.define('MyApp.store.Events', {
        extend : 'MyApp.store.Abstract',
    
        config : {
            rootProperty : 'data'
        }
    });
    And the rootProperty should be set on the reader.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

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