PDA

View Full Version : Extend store



westvovik
5 Nov 2010, 7:31 AM
Help to understand please as to expand object Ext.data.store, I should where to find the detailed information

Has found one example but hasn't absolutely understood as me it to adapt

Here my code



App.store = new Ext.extend(Ext.data.Store, {
restful: true,
autoLoad: false,
autoSave: true,
idProperty: 'id',
constructor: function() {
App.store.superclass.constructor.call(this, {
writer: new Ext.data.JsonWriter({writeAllFields: false}),
proxy: new Ext.data.HttpProxy({url: this.url}),
reader: new Ext.data.JsonReader({totalProperty: 'total', successProperty: 'success', idProperty: this.idProperty, root: 'data', messageProperty: 'message'}, this.dataArr)
});
}
});
Ext.reg("appstore", App.store);

But it doesn't work.

hendricd
5 Nov 2010, 3:36 PM
You're very close now, but:

reader takes fields:[] (or record), not data

plalx
5 Nov 2010, 10:13 PM
Also, remove the new keyword.

westvovik
6 Nov 2010, 11:22 AM
ok

this code is work but, no work baseParams


App.store = Ext.extend(Ext.data.Store, {
restful: true,
autoLoad: false,
autoSave: true,
idProperty: 'id',
constructor: function(config){
Ext.apply(config, {writer: new Ext.data.JsonWriter({writeAllFields: false})});
App.store.superclass.constructor.call(this, config);
this.proxy = new Ext.data.HttpProxy({url: this.url});
this.reader = new Ext.data.JsonReader({totalProperty: 'total', successProperty: 'success', idProperty: this.idProperty, root: 'data', messageProperty: 'message'}, this.dataArr);
}
});
Ext.reg("appstore", App.store);In general I want to make object on which base I will already create final object
and the help of this configuration already to create copies store



App.user.conf_store = Ext.extend(App.store, {
url:'app.php/Users',
dataArr: [
{name: 'id'},
{name: 'login'},
{name: 'password'},
{name: 'name'},
{name: 'birthdate', type: 'date', dateFormat: "Y-m-d"},
{name: 'mkdate', type: 'date', dateFormat: "Y-m-d H:i:s"},
{name: 'moddate', type: 'date', dateFormat: "Y-m-d H:i:s"},
{name: 'comment'},
{name: 'active',
type: 'bool'}
]});Accordingly as a result I receive ready object

var store = new App.user.conf_store();

But at function use

store.load(params:{'user_id': 1})

store doesn't transfer parameter dc

app.php/UsersContact?_dc=1289070343537

The object behaves obviously not as usually, I probably was mistaken where that in initialization, only I do not understand where exactly