1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    11
    Vote Rating
    0
    kof720551 is on a distinguished road

      0  

    Default [4.1b1]Ext.override doesn't work correctly

    [4.1b1]Ext.override doesn't work correctly


    I refer to Ext.data.AbstractStore constructor,and override add a line test code "alert('123');".
    This worked correctly in version 4.0.2a,but can't worked in 4.0.7/4.1pr/4.1b1.
    PHP Code:
      Ext.onReady(function () {
        
    Ext.override(Ext.data.AbstractStore, {
            
    constructor: function (config) {
                
    //test code
                
    alert('123');
                
                var 
    me this,
                      
    filters;
                
                
    Ext.apply(meconfig);
                
    me.removed = [];
                
    me.mixins.observable.constructor.apply(mearguments);
                
    me.model Ext.ModelManager.getModel(me.model);
                
    Ext.applyIf(me, {
                    
    modelDefaults: {}
                });
                if (!
    me.model && me.fields) {
                    
    me.model Ext.define('Ext.data.Store.ImplicitModel-' + (me.storeId || Ext.id()), {
                        
    extend'Ext.data.Model',
                        
    fieldsme.fields,
                        
    proxyme.proxy || me.defaultProxyType
                    
    });
                    
    delete me.fields;
                    
    me.implicitModel true;
                }
                if (!
    me.model && me.useModelWarning !== false) {
                    if (
    Ext.isDefined(Ext.global.console)) {
                        
    Ext.global.console.warn('Store defined with no model. You may have mistyped the model name.');
                    }
                }
                
    me.setProxy(me.proxy || me.model.getProxy());
                
    me.proxy.on('metachange'me.onMetaChangeme);
                if (
    me.id && !me.storeId) {
                    
    me.storeId me.id;
                    
    delete me.id;
                }
                if (
    me.storeId) {
                    
    Ext.data.StoreManager.register(me); 
               }
                
    me.mixins.sortable.initSortable.call(me);
                
    filters me.decodeFilters(me.filters);
                
    me.filters = new Ext.util.MixedCollection();
                
    me.filters.addAll(filters);
            }
        });
        
    Ext.define('Sharing.store.CamStore', {
            
    extend'Ext.data.Store',
            
    model'Sharing.model.CamModel',
            
    data: [
                { 
    "CamID""1""CamValue""1" },
                { 
    "CamID""2""CamValue""2" },
                { 
    "CamID""3""CamValue""3" },
                { 
    "CamID""4""CamValue""4" },
                { 
    "CamID""5""CamValue""5" },
                { 
    "CamID""6""CamValue""6" },
                { 
    "CamID""All""CamValue""0" }
            ]
        });

        
    Ext.create('Sharing.store.CamStore');}); 

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,582
    Vote Rating
    433
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    You should use Ext.define for overrides:

    Code:
    Ext.define('Override.data.AbstractStore', {
        override : 'Ext.data.AbstractStore',
    
        constructor : function(config) {...}
    });
    This allows to load the file dynamically if you setup a path for the Override namespace. You can call the parent code via this.callOverridden(arguments);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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