PDA

View Full Version : inheritance mechanism lacks



rnel
2 Nov 2012, 2:20 AM
Hi,

I'ùm trying to extend a store class but all way to define the proxy while definig the class failed. guys, what's the matter µ? Thanks.

here is the code :


Ext.define('Ext.dtp.pdw.stores.Profile', {

extend : 'Ext.data.JsonStore',

proxy : {
type : 'ajax',
url : 'profiles',
model : 'Ext.dtp.pdw.models.Profile',
reader : {
type : 'json',
root : 'profiles',
idProperty : 'id'
},
api : {
//destroy : 'users/delete',
read : 'profiles'
//update : 'users/update',
//create : 'users/create'
}

},


constructor : function(config){
this.callParent(config) ;
}

}) ;

the error message is that none of the properties defined for the proxy (i mean url, model, reader, ...) is seen once the class instantied.

vietits
2 Nov 2012, 2:44 AM
Because you extend from Ext.data.JsonStore so proxy setting will be overridden by Ext.data.JsonStore constructor:


Ext.define('Ext.data.JsonStore', {
extend: 'Ext.data.Store',
alias: 'store.json',
requires: [
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json',
'Ext.data.writer.Json'
],


constructor: function(config) {
config = Ext.apply({
proxy: {
type : 'ajax',
reader: 'json',
writer: 'json'
}
}, config);
this.callParent([config]);
}
});

Try to fix your code as below:


Ext.define('Ext.dtp.pdw.stores.Profile', {
//extend: 'Ext.data.JsonStore',
extend: 'Ext.data.Store',
model: 'Ext.dtp.pdw.models.Profile',

proxy : {
type: 'ajax',
url : 'profiles',
//model: 'Ext.dtp.pdw.models.Profile',
reader: {
type : 'json',
root : 'profiles',
idProperty : 'id'
},
api : {
//destroy : 'users/delete',
read : 'profiles'
//update : 'users/update',
//create : 'users/create'
}
},
constructor : function(config){
// this.callParent(config) ;
this.callParent([config]) ;
}

});

rnel
2 Nov 2012, 3:08 AM
Ok, i didn't notice that my proxy would be overriden. I'm still new to the 4.1.x, i'm a 3.3.x veteran. i works now.Thanks. Keep on the good job.;)